Database Application giving error on client PC
i made an app on c# which has database connection and application works fine on my developement pc! Application starts fine and everything else works fine which has开发者_如何学Go nothing to do with DB but it throw an error when i try to execute query ? I have Dotnetfx 2.0 installed on target machine what do i need to? Sql server?
Error is: An error has occured while establishing a connection to the server. When connecting to SQL server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified
p.s. its my first db application =S
SQL Server is a completely separate application from the application you wrote and are distributing. If your application does not connect to an existing SQL Server running somewhere on the network you will have to install and configure SQL Server as part of your application's installation.
In addition you will either need to install / create a database as part of your application's installation, or else your application needs to be able to detect the absence of the database and build it itself on first startup.
As Marek said, the connection string is the most likely culprit, and I believe on SQL 2008 you have to explicitly allow TCP connections via:
- SQL Server Configuration manager
- Select SQL Server Network
- Configuration Select Protocols for your instance
- Right click on TCP/IP and "Enable"
Make sure your connection string looks something like this:
"Server=(local)\\SQLEXPRESS;Database=Your_DB_Name_Here;uid=sa;pwd=password;"
精彩评论