Results 1 to 2 of 2

Thread: Selecting from a mysql

  1. #1

    Thread Starter
    New Member
    Join Date
    Dec 2003
    Posts
    2

    Selecting from a mysql

    ok, i have this code so far:

    VB Code:
    1. Dim conn As ADODB.Connection
    2.   Dim rs As ADODB.Recordset
    3.   Dim fld As ADODB.Field
    4.   Dim sql As String
    5.  
    6.   'connect to MySQL server using MySQL ODBC 3.51 Driver
    7.   Set conn = New ADODB.Connection
    8.   conn.ConnectionString = "DRIVER={MySQL ODBC 3.51 Driver}; SERVER=blah; DATABASE=blah; UID=blah; PWD=blah; OPTION=3"
    9.  
    10.   conn.Open
    11.  
    12.   Set rs = New ADODB.Recordset
    13.   rs.CursorLocation = adUseServer
    14.  
    15.   conn.Execute "SELECT name,ip FROM site_online WHERE name = '" & conlist.Text & "'"

    Most tutorials show me how to loop the results. But i will get only one result. How do i get that result?

  2. #2
    Fanatic Member
    Join Date
    Sep 2000
    Posts
    770
    Code:
        Set objRS = New ADODB.Recordset
        objRS.CursorLocation = adUseServer
      
        objConn.Execute "SELECT name,ip FROM site_online WHERE name = '" & conlist.Text & "
    
        While Not objRS.EOF
    
            strName = objRS.Fields("name")
            strIP = objRS.Fields("ip")
    
            objRS.MoveNext '-Moves to next record
        Wend
    
       '-Make sure you remember to cleanup after yourself!
       objConn.Close
       Set objRS = Nothing
       Set objConn = Nothing
    Last edited by nkad; Dec 10th, 2003 at 10:51 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width