Go4Expert (http://www.go4expert.com/)
-   Visual Basic ( VB ) (http://www.go4expert.com/forums/visual-basic/)
-   -   VB6 / MYSQL problem using "seek" (http://www.go4expert.com/forums/vb6-mysql-using-seek-t29578/)

nlgootee 29Mar2013 00:36

VB6 / MYSQL problem using "seek"
I use the following code in the change event of a vb6 textbox and load the result into a listbox. This is using DAO in an ACCESS database. It has worked great since 1994.

      Dim sFind As Variant
          sFind = txFind.Text
      If Len(SFind) > 0 Then
            MousePointer = 11
            Findmark = g_rsC.Bookmark
            g_rsC.Index = "LAST NAME"
              g_rsC.Seek ">=", sFind
            If g_rsC.EOF Then
                  g_rsC.Bookmark = Findmark
                  txFind.Text = ""
            End If
        End If

We are switching to ADO in a MYSQL database and I converted the code to:

    Dim cnFind As ADODB.Connection
    Set cnFind = New Connection
    cnFind.CursorLocation = adUseServer
    cnFind.ConnectionString = "DSN=MYFLOURISH"

    Dim rsFind As ADODB.Recordset
    Set rsFind = New Recordset
    Dim sFind As Variant
    sFind = txFind.Text
    With rsFind
        .CursorLocation = adUseServer
        .ActiveConnection = cnFind
        .Source = "Customer"
        .Index = "LAST NAME"
        .Seek ">=", sFind
        .CursorType = adOpenKeyset
        .LockType = adLockOptimistic
        .Open Options:=adCmdTableDirect
    End With

When I run it, I get a type mismatch error as soon as I type the first letter. I don't know if it is an ADO error or a MYSQL error. If anyone can help me out here, I would really appreciate it. TIA

shabbir 29Mar2013 09:04

Re: VB6 / MYSQL problem using "seek"
You don't need to create the same thread in VB as well as MySQL forum and I have deleted your other thread.

All times are GMT +5.5. The time now is 00:18.