tags:

views:

30

answers:

2

Hi, I have made the remote database backup (MSSQL Server 2005 Express) to the localhost, and I want to connect with that in my app. To do so, I've changed the connection string:

from

Data Source=190.190.200.100;Initial Catalog=myDataBase;User ID=myUsername;Password=myPassword;

to

Data Source=TOMEK\SQLExpress;Database=myDataBase;User ID=myUsername;Password=myPassword;

but the error appears: Format of the initialization string does not conform to specification starting at index 0

I can login to the Management studio with that login/pass, and also the user name that I login into sql server has role membership db_owner to that database

what's wrong with that connection string ?

A: 

Maybe try comparing what you are doing to what is found here:

http://www.connectionstrings.com/sql-server-2005

Mike Cheel
+2  A: 

Try one of the 2 options.

Data Source=foo\SQLExpress;Initial Catalog=bar;User Id=user;Password=pwd;

or

Server=foo\SQLExpress;Database=bar;User ID=user;Password=pwd;

They're equivalent, but not sure if you can mix/match

  • Server/Data Source
  • Database/Initial Catalog

Are you using a hardcoded string, or from a .config file? Does your username or pwd contain any characters that might need escaping in the .config file? i.e. slash, ampersand?

string connstr = @"Server=foo\SQLExpress;Database=bar;User ID=user;Password=pwd;";
SqlConnection conn = new SqlConnection(connstr);


<add name="ConnectionString" 
     connectionString="Data Source=.\SQLEXPRESS;Database=bar;User ID=user1;Password=&amp;foo;"
     providerName="System.Data.SqlClient" />
p.campbell
nope, still the same error
Tony
the connection string is hardcoded and login and pwd are only letters, I communicate with DB via XSD file
Tony