vb.net : is it possible to connect to sql server 2008 via odbc but not through vb.net code?
- by phill
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()