Sunday, February 19, 2012

connection string & location problems

In a VB6 app, I am using the following connection string to connect with a SQL Server 2005 database:

strDbConn = "Provider=SQLOLEDB;Integrated Security=SSPI;" & _
"Persist Security Info=False;Database=" & strDbName & ";" & _
"AttachDBFileName=" & DbPath & ";" 'Data Source=.\mssqlserver;"

I am getting the following error message:

Error No. -2147467259
[DBNETLIB][ConnectionOpen(Connect()).]SQL Server does not exist or access denied

All help appreciated.

Did you try to replace "." with the machine name?|||

I could do that but I shouldn't have to: at least not according to ms documentation. Besides, it doesn't help.

The following connection string for sqlexpress also works in the development subdirectory but nowhere else:

strDbConn = "Provider=SQLNCLI;Integrated Security=SSPI;" & _
"Persist Security Info=False;Database=" & strDbName & ";" & _
"AttachDBFileName=" & DbPath & ";Data Source=.\sqlexpress;" & _
"User Instance=True"

In any other directory, it gives the error:

Invalid connection string attribute

Obviously, that can't be true because it works in that one directory. It has something to do with the location.

After more than two weeks of seeking answers, I can only access databases that are in a development subdirectory, but the minute I try to deploy an app - sql server 2005 is lost.

Doesn't anybody have any idea what causes this?

|||

rwbogosian wrote:

In a VB6 app, I am using the following connection string to connect with a SQL Server 2005 database:

strDbConn = "Provider=SQLOLEDB;Integrated Security=SSPI;" & _
"Persist Security Info=False;Database=" & strDbName & ";" & _
"AttachDBFileName=" & DbPath & ";" 'Data Source=.\mssqlserver;"

I am getting the following error message:

Error No. -2147467259
[DBNETLIB][ConnectionOpen(Connect()).]SQL Server does not exist or access denied

All help appreciated.

hi rwbogosian,

You're trying to access sql server using the SQLOLEDB provider, just change the provider to the Sql Client : SQLNCLI.1
Is the (.\mssqlserver) instance existing? From your connectionstring it seems you want to connect to the local server with an instance name=MSSQLSERVER. You can substitute the dot(.) with <SERVERNAME>\<INSTANCENAME> or if it is using the default instance use the syntax <SERVERNAME>.

HTH,|||

Isn't SQLNCLI for sqlexpress? I've found sqlexpress far too troublesome to be useful and do not wish to use it. The server MSSQLSERVER does indeed exist. I have tried the connection string with the servername; it didn't help. Also, the software will be deployed to another computer(s) and it would not be practical to hardcode the servername. Thanks anyway.

I've resolved the problem by first creating a connection to master, then using sp_attach_single_file_db, then closing the connection, and finally, opening a new connection that attaches to the database.

|||

SQLNCLI is the Bative Client for SQLServer which ships with the Native Client from SQL Server. You can still use the SQLOLEDB Provider, to support features at SQL 2k level, but you wont get any feature at SQL2k5 level. THe SQLNCLI isn′t only for SQL Server Express, its the new SQL Native Client library which was divided form MDAC.

HTH, Jens Suessmeyer.

http://www.sqlserver2005.de

No comments:

Post a Comment