josh261
asked on
VB.net Cannot open connection to SQLExpress 2005
Hello. I am having problems finding out why I cannot open a connection to my local SQLExpress instance from a vb.net form. I have looked all over the internet, but nothing I have tried works. Can anyone offer help? Thanks!!
Here is my code...it bombs at the last line where the connection is opened.
Dim ConnStr As String = "Server=localhost;DataBase =TableDini ng;User Id=myName;Password=pwd@1!"
Dim sqlConnection As New Data.SqlClient.SqlConnecti on(ConnStr )
Dim strSQL As String = "SELECT * FROM table WHERE (PIN = 1111)"
Dim cmd As New Data.SqlClient.SqlCommand( strSQL, sqlConnection)
cmd.CommandType = CommandType.Text
cmd.Connection.Open()
Here is my code...it bombs at the last line where the connection is opened.
Dim ConnStr As String = "Server=localhost;DataBase
Dim sqlConnection As New Data.SqlClient.SqlConnecti
Dim strSQL As String = "SELECT * FROM table WHERE (PIN = 1111)"
Dim cmd As New Data.SqlClient.SqlCommand(
cmd.CommandType = CommandType.Text
cmd.Connection.Open()
ASKER
Thanks for the quick response!!
I tried what you suggested and still get the same error. Here's the error message I get:
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.
I tried what you suggested and still get the same error. Here's the error message I get:
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.
ASKER
Great article!!
I tried all of the things it said...and thought it should work but didn't.
One of the suggestions is made when finished was to use the command prompt utility OSQL to simulate a remote connection client. OSQL connected with no problems.
Could it be something with Visual Studio or the vb.net code?
I tried all of the things it said...and thought it should work but didn't.
One of the suggestions is made when finished was to use the command prompt utility OSQL to simulate a remote connection client. OSQL connected with no problems.
Could it be something with Visual Studio or the vb.net code?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
That worked. I just needed to add Data Source=localhost\sqlexpres s in the connections string.
Thanks for your help! You rock!
Thanks for your help! You rock!
Dim ConnStr As String = "Server=localhost;Database
(notice the change to Database and User ID)