我在后续代码中得到了网络相关实例的错误,该代码用于备份我的数据库 [英] I got the error of network related instance so on in follwing code which is used to take back up of my database
本文介绍了我在后续代码中得到了网络相关实例的错误,该代码用于备份我的数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
#region
string connString = "Data Source=" + ConfigurationManager.AppSettings.Get("SHAROON-PC\\SQLEXPRESS") + ";Initial Catalog=" + "Garment.mdf" + ";";
//UserID=" + ConfigurationManager.AppSettings.Get("user") + ";Password=" + ConfigurationManager.AppSettings.Get("password");
SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder(connString);
builder.AsynchronousProcessing = true;
using (SqlConnection con = new SqlConnection(builder.ConnectionString))
{
using (SqlCommand cmd = new SqlCommand("BACKUP DATABASE " + "Garment.mdf" + " TO DISK='" + "D:" + "\\" + ConfigurationManager.AppSettings.Get("DataBaseBackupsFolderName") + "\\" + "Garment.mdf" + ".bak'", con))
{
con.Open();
IAsyncResult result = cmd.BeginExecuteNonQuery();
// Wait for the command to complete
result.AsyncWaitHandle.WaitOne();
// End the execution and throw any eventual exception
cmd.EndExecuteNonQuery(result);
}
}
#endregion
推荐答案
我想下面提到的问题应该对你有所帮助
与SQL Server建立连接时发生与网络相关或特定于实例的错误。找不到服务器或无法访问服务器。 [ ^ ]
I think below earlier asked question should help you
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible.[^]
这篇关于我在后续代码中得到了网络相关实例的错误,该代码用于备份我的数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文