【问题标题】:error in transfering the database from service based to local database将数据库从基于服务的数据库传输到本地数据库时出错
【发布时间】:2013-01-28 13:48:40
【问题描述】:

我刚刚知道基于服务的数据库和本地数据库之间的差异,因此根据我的需要,我已将项目数据库转移到本地数据库,我质疑并发现我只需要替换主要的连接字符串里面的东西,我不需要在我的代码中添加和替换。现在我收到了我不知道如何解决的错误 我的本地数据库代码是

       SqlConnection con = new SqlConnection();
              SqlConnection conn = new SqlConnection();
              conn.ConnectionString = @"Data Source=E
    :\project\+project\WindowsFormsApplication1\Database1.sdf";
              SqlCommand cmd = new SqlCommand();
              cmd.Connection = conn;
              conn.Open();
              try
         {
             // something
          }

              catch (Exception)
          {
              MessageBox.Show("ERROR");

          }
              conn.Close();
          }

我在 conn.open 上遇到错误

 A network-related or instance-specific error occurred 
while establishing a connection to SQL Server. The server
 was not found or was not accessible. Verify that the
 instance name is correct and that SQL Server is configured 
to allow remote connections. (provider: SQL Network Interfaces,
 error: 26 - Error Locating Server/Instance Specified)

【问题讨论】:

    标签: c# sql-server


    【解决方案1】:

    您必须使用SqlCeConnectionSqlCeCommand 而不是SqlConnectionSqlCommand

    示例:http://www.dotnetperls.com/sqlce

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-11-08
      • 1970-01-01
      • 1970-01-01
      • 2014-05-19
      • 1970-01-01
      • 2014-11-04
      • 1970-01-01
      相关资源
      最近更新 更多