VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Connects to access w/o connection string. will pull data and give user possibility to modify data.

by Nicholas Varvouletos (1 Submission)
Category: Databases/Data Access/DAO/ADO
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Thu 20th November 2003
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Connects to access w/o connection string. will pull data and give user possibility to modify data.

API Declarations


Dim RecordSet As New ADODB.RecordSet
Dim i As Integer
Dim ConnectionAccess As String

Rate Connects to access w/o connection string. will pull data and give user possibility to modify data.



    RecordSet.Close
    Set RecordSet = Nothing
End Sub

Private Sub cmdOpen_Click()
    Dim errLoop As Error
    Dim strTmp As String
    
    ConnectionAccess = "Driver={Microsoft Access Driver (*.mdb)};" & _
                  "Dbq=db1.mdb;" & _
                  "DefaultDir=I:\my senior project;" & _
                  "Uid=Admin;Pwd=;"

    On Error GoTo AdoErrors_found

    On Error GoTo AdoErrorLite_found

    RecordSet.Open "SELECT * FROM Products", ConnectionAccess, adOpenForwardOnly
    
    RecordSet.MoveFirst
    MsgBox (RecordSet.fields(0).Value)
    Exit Sub
    
CleanUp:

    Set RecordSet = Nothing
    Set Cmd1 = Nothing
    Set Conn1 = Nothing
    Exit Sub
AdoErrors_found:
    i = 1
    On Error Resume Next
    Set Errors_Found = Conn1.Errors
    For Each errLoop In Errors_Found
     With errLoop
        strTmp = strTmp & vbCrLf & "ADO Error # " & i & ":"
        strTmp = strTmp & vbCrLf & "   ADO Error   # " & .Number
        strTmp = strTmp & vbCrLf & "   Description   " & .Description
        strTmp = strTmp & vbCrLf & "   Source        " & .Source
        i = i + 1
     End With
    Next

AdoErrorLite_found:
    strTmp = strTmp & vbCrLf & "VB Error # " & Str(Err.Number)
    strTmp = strTmp & vbCrLf & "   Generated by " & Err.Source
    strTmp = strTmp & vbCrLf & "   Description  " & Err.Description
    MsgBox strTmp
    On Error GoTo 0
    GoTo CleanUp

End Sub

Download this snippet    Add to My Saved Code

Connects to access w/o connection string. will pull data and give user possibility to modify data. Comments

No comments have been posted about Connects to access w/o connection string. will pull data and give user possibility to modify data.. Why not be the first to post a comment about Connects to access w/o connection string. will pull data and give user possibility to modify data..

Post your comment

Subject:
Message:
0/1000 characters