Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DSN connection issue

Status
Not open for further replies.

nickspace

IS-IT--Management
May 2, 2005
43
0
0
US
I get an error when I attempt to connect to SQL Express using VB.net. I am attempting to use a System DSN previously created using the ODBC Data Source Administrator. The DSN was tested using MS Access by linking the tables. (Inserts... Updates and etc. all working) The code that fails is when I use opt1 as the connection string. opt2 works. SQL Express is installed locally and running. SQL Browser is also running. ALL protocols are enabled in the SQL Server Configuration manager. No firewall on.

OS is VISTA Home Premium SP1


Here is my Code:
Dim conn As New SqlClient.SqlConnection() : Dim cmd As New
SqlClient.SqlCommand()
opt1 = "Data Source=myDSN_Name;Initial Catalog=" & Me.dbname.ToString & User Id=" & Me.Usr.ToString & ";Password=" & Me.pwd.ToString & ";" opt2 = "Server=myMachineName\sqlexpress;Initial Catalog=" & Me.dbname.ToString & User Id=" & Me.Usr.ToString & ";Password=" & Me.pwd.ToString & ";" conn.ConnectionString = IIf(Me.option1.Checked, opt1.ToString,
opt2.ToString)
conn.Open()
cmd.Connection = conn
cmd.CommandText = inSQL
cmd.ExecuteNonQuery()
The error thrown for opt1 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: TCP Provider, error: 0 - No such host is known.)



Any and all help appreciated.
 
I never use SQL Server, so I'm just guessing here.
Code:
;Initial Catalog=" & Me.dbname.ToString [blue]& ";"[/blue] & User Id=" & Me.Usr.ToString &

Hope this helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top