[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.odbcnet

Trouble connection using OBDC

drv

9/6/2002 8:58:00 PM

I cannot connect to a SQL Server using a DSN.Can anyone
tell me what is wrong. I have included the code below:

Friend Function GetConnection(ByVal strDSN As String) As
Microsoft.Data.Odbc.OdbcConnection

If strDSN Is Nothing Then Return Nothing
If strDSN = "" Then Return Nothing
Dim strConnectionString As String = "dsn=" & strDSN
Dim oConn As OdbcConnection
Try
oConn = New OdbcConnection(strConnectionString)
oConn.Open()
Return oConn
oConn.Dispose()
Catch eGen As Exception

Finally

End Try
End Function
1 Answer

(Hussein Abuthuraya(MSFT))

9/7/2002 3:06:00 AM

0

The connection string maybe incomplete where you have to add the user name and password depending on how you created the DSN.

Here are some questions:
- Did you test the connection after you created it from the ODBC Admin.?
- Are you connecting from Windows or Web For?
If windows then the DSN may be User DSN or System DSN, however if Web for then it must be System DSN.
- What is the error message?
- Can you verify and use this DSN from a UDL file?
- What happen if you try: "DSN=" & strDSN & ";UID=userid;PWD=password"?
- Is this named instance SQL Server?
- Is your SQL Server setup to use Mixed authentication or just SQL?
- Is SQL Server on the same box or different machine?

As you can see providing more information may lead to the problem and hence providing a solution?


Thanks,
Hussein Abuthuraya
Microsoft Developer Support

This posting is provided "AS IS" with no warranties, and confers no rights.

Are you secure? For information about the Microsoft Strategic Technology Protection Program and to order your FREE Security Tool Kit, please visit
http://www.microsoft.co....