如何使用此连接字符串进行备份 [英] how to backup with this connection string

查看:56
本文介绍了如何使用此连接字符串进行备份的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hi Professional
我想从我项目中的数据库进行备份
我的连接字符串是:

@"Data Source =.\ SQLEXPRESS; AttachDbFilename = | DataDirectory | \ myDatabase.mdf;
初始目录= myDatabase;集成安全性= True;用户实例= True;

但发生错误

hi Professional
I want to backup from database in my project
my connection string is:

@"Data Source=.\SQLEXPRESS; AttachDbFilename=|DataDirectory|\myDatabase.mdf;
Initial Catalog=myDatabase;Integrated Security=True;User Instance=True";

but occurred error

推荐答案

您做错了.

我知道这个答案似乎含糊不清,但与您提出的问题相符.

您将得到什么错误-完全正确.
You''re doing it wrong.

I know this answer seems vague, but it matches the quality of your question.

WHAT error are you getting - EXACTLY.


如果您可以使用此字符串连接到数据库以查看记录,那么您还应该能够备份数据库:没有指定您的操作方式,我们无法为您调试该部分,但是这里有一个示例:
If you can connect to the database using this string in order to view records, then you should also be able to backup the database: Since you don''t specify how you are doing that we can''t debug that part for you, but there is an example here: http://www.geekpedia.com/tutorial180_Backup-and-restore-SQL-databases.html[^]


我确信下面的链接将对您有很大帮助. br/>
i am sure that this below link will help you a lot.
LINK
just read and follow instruction.

here is code spinet.

To BACKUP and RESTORE DataBase through SQLCMD.EXE :
PATH OF EXE:- C:\Program Files\Microsoft SQL Server\100\Tools\binn\SQLCMD.EXE
sqlcmd -S.\SQLExpress
1> BACKUP DATABASE dbName TO DISK = ''path''
2> GO
An alternative, single-line backup command:

sqlcmd -S.\SQLExpress -Q"BACKUP DATABASE dbName  TO DISK = ''path''"
(Note that you must enclose the path within quotes)

To Restore:

sqlcmd -S.\SQLExpress
1> RESTORE DATABASE dbName FROM DISK = ''path''
2> GO

For Restore with REPLACING EXISTING DATABASE
1> RESTORE DATABASE dbName FROM DISK = ''path''
2> WITH REPLACE
3> GO


这篇关于如何使用此连接字符串进行备份的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆