Hi all,
I am novice in the c #.
Having completed the Application contains SQL database.
But when I run on another machine gives me an error message as follows:


Please note that I have the installation of the .net framework, And the connection string I used is:

SqlConnection cn = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\MyData.mdf;Integrated Security=True;User Instance=True");

Please Help me...

This error happens because the .\sqlexpress in your connection specified that the database engine you are trying to connect to resides on the local machine from where your application is runing. change the dot to the name of the machine where the database resides and make sure you enable remote connection of the SQL database through the surface area configuration. To enable remote connection follow this steps. All Programmes--->Microsoft SQL Sever2005--->Configuration Tools--->SQL sever surface area configuration-->Surface Area Configuration for services and Connection--->Remote connection check the local and remote connection radio button. Hope this helps

Thank's ema005,
I changed the . by the machine name, and application it worked on my machine but on the nother machine it not worked !!!
Please note that I have the installation of the .net framework on other machine but SQL server not installed on it.

Thank you for reply...
The problem is solved, But how I can use SQL database without install Sql Express on client machine???

Do you want to connect to a central server and don't want to install sql express because they aren't hosting the database, or do you want to ship a database with the application but not require sql express?

yes Scott Knake, you are understand me...
I want to ship a database with the application but not require sql express

Please tell me if I can doing this....

You can but not if you want to use MSSQL. Unfortunately that database requires an installation. Almost all databases do unless you use a form of flat file. Is there a particular reason you don't want to have the end user install the application?

You could use SQL Server Compact which has significantly less overhead than a traditional SQL Server but it still requires an installation:

Friend, someone told me in one of the forums: I can work a program with the SQL database without the installation SQLexpress. only the .Net framework installation

This is right??

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