CAN I RUN A QUESTION THAT I HAVE IN CREATED IN THE ACCESS FROM THE VB6 ?

vb6 Greece
  • 13 years ago

    HOW CAN I RUN A QUESTION THAT I HAVE IN CREATED IN THE ACCESS FROM THE VB6 ?

  • 13 years ago

    Nikos,

    I appreciate that English may not be your first language, but you will get a better response if you try and post a clear explanation of your problem including any code you have written already, a definition of your database structure etc.  If you have problems writing english there are many online translators that you can use:
    http://babelfish.altavista.digital.com/babelfish/tr

    The following code gives an example of accessing a database from VB6:

    'Note: you must add a reference to the Microsoft ActiveX 2.x Object Library 
    Dim rs As ADODB.Recordset
    Dim cn As ADODB.Connection
    Set cn = New ADODB.Connection
    Set rs = New ADODB.Recordset
    strDBPath = "myDB.mdb"
    With cn
        .Provider = "Microsoft.Jet.OLEDB.4.0"
        .ConnectionString = "Data Source= " & strDBPath
        .CursorLocation = adUseClient
        .Open
    End With
    strSQL = "select * from myTable"
    With rs
            .ActiveConnection = cn
            .CursorLocation = adUseClient
            .CursorType = adOpenForwardOnly
            .LockType = adLockOptimistic
            .Open strSQL
    End With
    If ((rs.BOF <> True) And (rs.EOF <> True)) Then
         'You now have a recordset which contains the records returned by your SQL query
         'To refer to a record you can use several techniques:
         'Refer to the fields by numeric reference (0 based):
         Debug.Print rs.Fields(0)
         'Refer to them by name:
         Debug.Print rs.Fields("Field1")
         'Use a "Bang"
         Debug.Print rs!Field1
    End If



































Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“An idiot with a computer is a faster, better idiot” - Rich Julius