Datenbank connect

  • VB6

    Datenbank connect

    Hallo
    noch eine frage:

    Habe in List1 x Objekte. beim Programm start habe ich folgendes ausgeführt:

    <pre>
    in einem Modul:

    Public Declare Sub Sleep Lib "kernel32.dll" (ByVal dwMilliseconds As Long)

    Public cnMySql As New rdoConnection
    Public rdoQry As New rdoQuery
    Public rdoRS As rdoResultset

    Public sDB As String
    Public sTable As String
    Public bConnection As Boolean


    in einer Form
    sDB = GetSetting(App.Title, "Settings", "LastDB", "dbmusic")
    sTable = GetSetting(App.Title, "Settings", "LastTable", "files")


    lblConnected.Caption = "Connected to " & sDB
    lblLoading.Caption = "Loading files from " & sTable

    DoEvents

    Sleep 1000

    DoEvents

    cnMySql.CursorDriver = rdUseOdbc
    cnMySql.Connect = "uid=root;pwd=;server=localhost;driver={MySQL ODBC 3.51 Driver};database=" & sDB & ";dsn='';"
    cnMySql.LoginTimeout = 10000
    cnMySql.EstablishConnection

    DoEvents

    bConnection = True

    Sleep 1000

    picConnected.BackColor = &HC000&
    DoEvents

    ' set up a remote data object query
    ' specifying the SQL statement to run.


    picLoading.BackColor = &HC000&

    DoEvents

    With rdoQry
    .Name = "selectUsers"
    .SQL = "select * from " & sTable
    .RowsetSize = 1
    Set .ActiveConnection = cnMySql
    Set rdoRS = .OpenResultset(rdOpenKeyset, rdConcurRowVer)
    End With
    ' loop through the record set processing the
    ' records and fields.

    Sleep 1000




    Dim iId As Integer
    iId = 1

    Do Until rdoRS.EOF
    frmShow_Files.lsvFiles.ListItems.Add , , iId
    frmShow_Files.lsvFiles.ListItems(frmShow_Files.lsvFiles.ListItems.Count).ListSubItems.Add , , rdoRS!sArtist
    frmShow_Files.lsvFiles.ListItems(frmShow_Files.lsvFiles.ListItems.Count).ListSubItems.Add , , rdoRS!sTitel
    frmShow_Files.lsvFiles.ListItems(frmShow_Files.lsvFiles.ListItems.Count).ListSubItems.Add , , rdoRS!sPfad

    With rdoRS

    .MoveNext
    End With

    iId = iId + 1
    Loop

    ' close record set
    ' close connection to the database


    Sleep 2000

    DoEvents

    rdoRS.Close
    cnMySql.Close
    </pre>

    jetzt habe/hatte ich eine Verbindung.
    Besteht diese Verbindug noch?

    so jetzt moechte in in der Form mit dem LIst1 objekt eine Verbindung zu dieser DB und diesem Table aufbauen. wie kann ich dan machen???