John said:
The connection string is just as I see it documented in dozens of
places:
S =
"Server=.\SQLExpress;AttachDbFilename=C:xxx.mdf;Database=xxx;Trusted_Con
nection=Yes;"
Yet, the connection fails.
Am i missing something obvious?
-zorpie
I detached one of my databases, then used your connection string (with a
full path to the .mdf file) to create a SqlConnection (and retrieve
data) without problems.
Normally, however, I would just restore/attach my database (using
Microsoft SQL Server Management Studio Express), then use one of the
following connection strings:
sCnn = "Data Source=MyServer;Initial Catalog=MyDB;User
Id=MyUser;Password=MyPassword;"
sCnn = "Server=MyServer;Database=MyDB;User
ID=MyUser;Password=MyPassword;Trusted_Connection=False;"
sCnn = "Data Source=MyServer;Initial Catalog=MyDB;Integrated Security=SSPI;"
sCnn = "Server=MyServer;Database=MyDB;Trusted_Connection=True;"
sCnn = "Server=MyServer\SQLEXPRESS;Database=MyDB;Trusted_Connection=True;"
sCnn = "Server=MyServer;Database=MyDB;User
ID=sa;Password=MyPassword;Trusted_Connection=False;Packet Size=4096;"
sCnn = "Data Source=127.0.0.1,1433;Network Library=DBMSSOCN;Initial
Catalog=MyDB;User ID=MyUser;Password=MyPassword;"
HTH