如何使用.NET连接到SQL Server中的特定数据库

时间:2015-02-06 19:11:23

标签: sql .net sql-server connection

下面连接数据库的代码,你能告诉我哪里弄错了吗?

   SqlConnectionStringBuilder setting = new SqlConnectionStringBuilder();
    setting.DataSource = ".\\SQLExpress";
    setting.InitialCatalog = "PCM_NEW";
  //  setting.UserInstance = true;
    setting.IntegratedSecurity = true;
    setting.AttachDBFilename = @"C:\Program Files\Microsoft SQL Server\MSSQL12.SQLEXPRESS\MSSQL\DATA\PCM_NEW.mdf";


    //setting.UserID = "LKALAY\\SQLEXPRESS";

    SqlConnection baglanti = new SqlConnection(setting.ConnectionString);
    return baglanti;

我收到错误:

  

错误:提供者:SQL网络接口,错误:26

0 个答案:

没有答案