vb.net : is it possible to connect to sql server 2008 via odbc but not through vb.net code?

Posted by phill on Stack Overflow See other posts from Stack Overflow or by phill
Published on 2011-01-06T19:48:08Z Indexed on 2011/01/06 19:53 UTC
Read the original article Hit count: 219

Filed under:
|

I'm supporting an old vb.net program whose database it connected to was moved from SQL Server 2005 to SQL Server 2008. Is there a setting on SQL Server 2008 which will allow ODBC connections to access the database but not allow VB.NET to connect to it programmatically?

the error i keep receiving in the app is:

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)

however I can connect to it when I create a system dsn to the sql server instance and through VS2005's Tools >> Connect to Database.

Here is the code I'm using to connect:

dim strC as string 
strC = "data source=bob; database=subscribers; user id=bobuser; password=passme" 
dim connection as New SqlClient.SqlConnection(strC)  
try     
   connection.open() 
catch ex as Exception     
   msgbox(ex.message) 
end try  
connection.Close()

© Stack Overflow or respective owner

Related posts about vb.net

Related posts about sql-server-2008