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:

http://img103.herosh.com/2009/09/02/819895428.jpg

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...

Recommended Answers

All 8 Replies

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???

Mark this thread as solved and start another thread.

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:
http://msdn.microsoft.com/en-us/library/ms174619.aspx

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??

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.