如题,用C#写的程序,出现的错误是:项“attachdbfilename”的值无效
请问这是什么问题,怎么解决!
谢谢!

解决方案 »

  1.   

    没有问错地方,我用的是Microsoft SQL Server2005
      

  2.   

    不建議你修改SQL服務器名,尤其是在同一局域網的,建議你在程序SQL連接代碼裏面修改,全部替換即可。
      

  3.   

    是在MicroSoft SQL Server Management Studio Express里面修改吗?
      

  4.   

    string DataPath = Application.StartupPath.Substring(0, Application.StartupPath.Substring(0, Application.StartupPath.LastIndexOf("\\")).LastIndexOf("\\"));
                DataPath += @"\DataBase\FMSDatabase.MDF;";   
                fmsConnectString = @"Data Source=(local)\sqlexpress;AttachDbFilename=" + DataPath + "Integrated Security=True;User Instance=True;";
                fmsConnection = new SqlConnection(fmsConnectString);
                fmsConnection.Open();
                return fmsConnection;
    这是我写的连接数据库的代码,请大虾指教一下该怎么修改?
      

  5.   

    附加了,我在MicroSoft SQL Server Management Studio Express里面附加数据库了!但是不行啊
      

  6.   

    Str1 = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=ZSDLdb;Data Source=XI-GPL"这个是我的程序中的,VB里编的
    换计算机后,Data Source=XI-GPL
    这个就要根据另一台所装的server的服务器名将“XI-GPL”更改为新的了
    希望对你有帮助!
    因为你用的是Application,我也不是很懂!
      

  7.   

    我另外一台机子上的MicroSoft SQL Server Management Studio Express里面的数据库引擎名称为:B3EAD37EB46A408\SQLEXPRESS
    我把(local)\sqlexpress改成了B3EAD37EB46A408\SQLEXPRESS
    但是还是出现如下错误:
    无法打开登陆所请求的数据库“FMSDatabase”。登陆失败。
    用户'B3EAD37EB46A408\Administrator'登陆失败。
    请问这是怎么回事呢?
      

  8.   

    Set myConn = New ADODB.Connection
    myConn.ConnectionString = "driver={SQL Server};" & _
    "server=YOURSQLSERVERNAME;uid=sa;pwd=yourpassword;database=databasename"
    myConn.Open
      

  9.   

    对了,我在另外一台机子上面是可以在MicroSoft SQL Server Management Studio Express里面打开我拷贝的数据库的,
    而且数据都是正确的,就是在程序里面打不开,不知道是什么原因?