VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



DSN-less logon to a SQL Server database

by Jim Rhoades (2 Submissions)
Category: Miscellaneous
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Sun 12th September 1999
Date Added: Mon 8th February 2021
Rating: (1 Votes)

DSN-less logon to a SQL Server database

Rate DSN-less logon to a SQL Server database



'Purpose: Logon to SQL Server....
        Dim CN1 As New ADODB.Connection
        Dim sAdoConStr As String
        
        On Error GoTo LogonError
        
        sAdoConStr = "UID=SA" & _
                 ";PWD=" & _
                 ";Server=Server123" & _
                 ";Database=MyDataBase" & _
                 ";App=My Application Name"
        
        With CN1      ' Establish DSN-less connection
             .ConnectionString = sAdoConStr
             .ConnectionTimeout = 60
             .CommandTimeout = 60
             .CursorLocation = adUseClient
             .Provider = "SQLOLEDB"
             .Open
        End With
        
        GoTo LogonExit

LogonError:
        MsgBox "Please contact your Network or Database Administrator." & _
               "Inform them that you are unable to connect to the Server." & _
               vbCrLf & "The following Error number was generated: " & Err.Number & _
               vbCrLf & Err.Description, vbOKOnly + vbInformation, "LOGON ERROR"
        End
LogonExit:
End Sub


Download this snippet    Add to My Saved Code

DSN-less logon to a SQL Server database Comments

No comments have been posted about DSN-less logon to a SQL Server database. Why not be the first to post a comment about DSN-less logon to a SQL Server database.

Post your comment

Subject:
Message:
0/1000 characters