Dim db As New Connection
'Dim tbpro As New ADODB.Recordset
'Dim db As Database
Dim tbpro As Recordset
Private Sub Command1_Click()
rsMyRecordset.Open (App.Path & "\" & "super.mdb")
End Sub

Private Sub Form_Load()

'db.ConnectionString = (App.Path & "\" & "super.mdb")
'tbpro.ActiveConnection "table1", db, adOpenDynamic, adLockOptimistic
db.Open (App.Path & "super.mdb")

Set tbpro = db.OpenRecordset("table1")

End Sub
The above code can't work, It will leave an error message "Data source name is too large".
Please tell me how do i can solve it?

2 Years
Discussion Span
Last Post by ranod

How could it work. You write a wrong syntax to assign the connection string.
You must mention the name of the provider, through which you can open the database. Your codes should be

'Declaring Variables
Dim db As New ADODB.Connection      'Database connection object
Dim tbpro As New ADODB.Recordset    'Database recordset object

Private Function getrecordset(cnnConnection As ADODB.Connection, sQry As String) As ADODB.Recordset

          'Creating a function to open a recordset object

      Dim rstrecord As ADODB.Recordset
          Set rstrecord = New ADODB.Recordset

          rstrecord.CursorType = adOpenDynamic
          rstrecord.LockType = adLockPessimistic
          rstrecord.CursorLocation = adUseClient
          rstrecord.Source = sQry
          Set rstrecord.ActiveConnection = cnnConnection
          Set getrecordset = rstrecord

End Function

Private Sub Command1_Click()
    'Opening connection

    'Initializing and opening recordset
    Set tbpro = getrecordset(db, "Write your SQL Statenment here")

    'Do Jobs to maintain your table
    'Do jobs to insert data in table
    'Do jobs to retrieve data from table

    'After doing work close recordset
    Set tbpro = Nothing

    'Close Database connection

End Sub

Private Sub Form_Load()

    db.ConnectionString = "DRIVER=Microsoft Access Driver (*.mdb);DBQ=" & App.Path & "\" & "super.mdb" & ";"


End Sub

Hope it help you.


hello, I wanna ask about how to add a video into visual basic 6.0
I try it once, when I insert it to the VB and delete it from my computer it cant play anymore . If I bring it back its work.
because I wanna do some project and send it "include the videos I want" to someone.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.