lbsi
asked on
Using a DSN connection in a VB.net program
Good Afternoon
I use the following code to build my connection string in VB.net:
Dim BuildConnectionString As String
BuildConnectionString = "DSN=" + g_DSNName + ";UID=" + g_UserId + ";PWD=" + g_Password
Dim odbcConnect As New OdbcConnection(BuildConnec tionString )
Being that my DSN is set-up with sa, I am not really sure I fully understand how the connection string actually works.
Is the UID and PWD, used in the connection string, the ones in the DSN or is the UID and PWD for connecting to the database once the DSN gets
you to the server?
Thanks,
Ed
I use the following code to build my connection string in VB.net:
Dim BuildConnectionString As String
BuildConnectionString = "DSN=" + g_DSNName + ";UID=" + g_UserId + ";PWD=" + g_Password
Dim odbcConnect As New OdbcConnection(BuildConnec
Being that my DSN is set-up with sa, I am not really sure I fully understand how the connection string actually works.
Is the UID and PWD, used in the connection string, the ones in the DSN or is the UID and PWD for connecting to the database once the DSN gets
you to the server?
Thanks,
Ed
Ed,
Are you getting any error from your code? Are you using windows authetication, DB server credentials? If windows authentication are using , just need DSN in connection string.
If you are getting error from above code add 'Trusted_Connection=False' in your connection string.
Thad
Are you getting any error from your code? Are you using windows authetication, DB server credentials? If windows authentication are using , just need DSN in connection string.
If you are getting error from above code add 'Trusted_Connection=False'
Thad
Go here for more examples: http://www.connectionstrings.com/
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I apologize for not accepting the answer from Dimandja. The information assisted me in finding the solution. Please assign point total to Dimandja. In the future, I will be more diligent in accepting answers and assigning points.
Thanks,
Ed
Thanks,
Ed
Example using DSN:
Dim sConnString = "DSN=Pubs_DSN"
Dim oODBCConnection = New Odbc.OdbcConnection(sConnS
Try
oODBCConnection.Open()
Catch ex As Exception
MsgBox(ex.Message)
End Try
Example DSN-less:
Dim connectionString = "Driver={SQL Server};Server=SQLserverna
Dim oODBCConnection = New Odbc.OdbcConnection(connec
Try
oODBCConnection.Open()
Catch ex As Exception
MsgBox(ex.Message)
End Try
Pubs_DSN is:
Data Source Name: Pubs_DSN
Server: <SQLservername>
Database: pubs
Use Integrated Security: Yes