I m trying to connect an sql express database over lan. my connection string is as below.

Data Source=Mr-4f04a26307ff\sqlexpress; AttachDBFilename=F:\\Projects\\MyProj\\FirstProj\\bin\\Debug\\Database\\MyDB.mdf;Integrated Security=ture; User Instance=true;

but unable to connect and throw this exception
Login Failed for user 'Mr-4f04a26307ff\Guest'

What is the problem with this and what is the solution.
thnx

Right click your desktop and create a new text file. Rename that text file to Connection.udf. Double click this file to run it and test your database connection. Once you have all the settings the way you want, close the program. You can now open the UDF file in notepad and you have a proper connection string.

The other thing is to make sure that it allows remote connections. Not sure if SQL Express has this but look for the SQL Server Surface Area Configuration tool and look under DB Engine and then Remote Connections. Check off Using both TCP/IP and named pipes.

Hope this helps.

Remove that name out of connection string, use only this:

Data Source=\sqlexpress; AttachDBFilename=F:\\Projects\\MyProj\\FirstProj\\bin\\Debug\\Database\\MyDB.mdf;Integrated Security=ture; User Instance=true;

or:

"Data Source=.\\SQLEXPRESS;AttachDBFilename=F:\\Projects\\MyProj\\FirstProj\\bin\\Debug\\Database\\MyDB.mdf;Integrated Security=ture; User Instance=true;

Edited 5 Years Ago by Mitja Bonca: n/a

thnx for your help
Would you like to explain a bit more about the connection.udf.
I have done all the steps required for sharing the database.
but remain same.

Login Failed for user 'Mr-4f04a26307ff\Guest'

This problem can be easily solved using sql server management studio. You have to add guest user to the sql server.

This article has been dead for over six months. Start a new discussion instead.