Working with ASP this connection works:
stringMyConn = "dsn=foo.com.bar;uid=john;pwd=xxxx;"
set myConn = Server.CreateObject("ADODB.Connection")
myConn.open stringMyConn
But it doesn't with ASP.NET
Dim myConn As SqlConnection = New SqlConnection("dsn=foo.com.bar;uid=john;pwd=xxxx;")
myConn.Open
What am I doing wrong? Thank you very much.
Since you are connecting to SQL Server, I don't recommend that you use a DSN connection. You can connect to SQL server as follows:
Dim myConn As New SqlConnection("server=;database=;user id=;password=;")
Dim myCmd As New SqlCommand("SELECT * FROM SOMETHING", myConn)
myConn.Open()
' ... Some code here to do something with the SqlCommand object
myConn.Close()
For future reference, a good source for connection strings isConnectionStrings.com.
No comments:
Post a Comment