Showing posts with label 32-bit. Show all posts
Showing posts with label 32-bit. Show all posts

Monday, March 26, 2012

Moving a database application to SQL Server 2005 Express

I have been programming an application with VC++ 2005 and SQL Server 2005. I have converted an old 16-bit database to 32-bit managed code and SQL server and the application seems to be good. Now I want to deploy the application to another server for testing.

I have installed XP SP2, Windows Installer 3.1, Net framework 2.0 and SQL Server 2005 express to the test server. I have transferred the application with WI 3.1 and the program works well in the test server till the first SQL command. I have made a back up of the database and restored it in the test server. In the test server I can log in the database with Server Management studio and I can read the data there correctly. I have enabled both named pipes and TCP/IP for the database in the test server. With Surface Area Configuration I have enabled Local and Remote Connections Using both TCP/IP and named pipes. I only need Windows authentication at this time.

After all this when I come to the first SQL command in the application on the test server I receive the error message:
An error has occurred 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: Named Pipes Provider, error: 40 – Could not open a connection to SQL Server).

My connection string to the database is:
'connection->ConnectionString = "Persist Security Info=False; Integrated Security =SSPI;"
"Data Source=TESTSERVER; Initial Catalog=TESTDATABASE;";'

When I use "Data Source=DevelopmentServer", the application works well on the development server.

Can't understand what is still wrong. Can you possibly have an answer for me?

hi,

are you connecting locally or from remote clients?

check with the SQL Server Configuration Manager the appropriate network protocols are enabled as well..

regards

|||

Thank you for your answer!

Actually I am connecting to the TestServer only locally. I enabled TCP/IP and named pipes only because of the error message (40) and I enabled those features using SQL Server Configuration Manager as you suggest. This is done but I still receive the error.

|||

Finally, the solution found!

When connecting to the TestServer the connection is not actually to the server but the instance. The connection string must have format TestServer\SQLExpress. I had this and the compiler could compile and link the code without errors, but there was a warning of wrong character sequence. When I have to repeat the connection command repeatedly, I had defined the string with

#define COMMANDSTRING "Data Source=TestServer\SQLExpress"

The correct format is

#define COMMANDSTRING "Data Source=TestServer\\SQLExpress"

although the backslash is within quotation marks.