Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > Pro VB Databases
Password Reminder
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Pro VB Databases Advanced-level VB coding questions specific to using VB with databases. Beginning-level questions or issues not specific to database use will be redirected to other forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro VB Databases section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old January 23rd, 2006, 04:46 PM
Registered User
Join Date: Dec 2005
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Connecting to MySQL Database from VB2005

Hey folks :)

I'm trying to connect to a MySQL database using VB2005.
I have made a small module, and it works just fine. I used ADO to connect with.
Now i have my problem: How do I extract the values from the table?
I can count the number of rows, but i cant find a way to actually show the data from a speific column in fx a ListBox.

I would be very happy if someone could help me with this!
Here's my code:

Module modConnect
    Dim strDataBaseName As String
    Dim strDBCursorType As String
    Dim strDBLockType As String
    Dim strDBOptions As String
    Dim rs As ADODB.Recordset
    Dim cn As ADODB.Connection

    Public Function Connect() As Boolean
        Dim intCount As Long
        Dim strSQL As String

        cn = New ADODB.Connection

        With cn
            .CommandTimeout = 0
            .CursorLocation = ADODB.CursorLocationEnum.adUseClient
        End With

        rs = New ADODB.Recordset

        strSQL = "SELECT * FROM radio"

        rs.Open(strSQL, cn, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic)

        If Not rs.EOF Then
            For intCount = 1 To rs.RecordCount
                'Its here i want to get the data from a specific column and show it in my
            Next intCount
        End If
    End Function

    Private Function ConnectString() As String
        Dim strServerName As String
        Dim strDatabaseName As String
        Dim strUserName As String
        Dim strPassword As String

        strServerName = ""
        strDatabaseName = "radiocenter"
        strUserName = "admin"
        strPassword = "1234"

        ConnectString = "DRIVER={MySQL ODBC 3.51 Driver};" & "SERVER=" & strServerName & ";DATABASE=" & strDatabaseName & ";" & "USER=" & strUserName & ";PASSWORD=" & strPassword & ";Port=3306;" & Chr(34) & ";"
    End Function
End Module

Thanks in advance!

- Tank

Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Help connecting to mysql database catalog ajrobson Servlets 0 December 28th, 2006 04:24 PM
Need Help Connecting to mySQL Database! jehchoi1 PHP Databases 6 April 21st, 2005 09:28 AM
database connecting with java &mysql rakeshkumar MySQL 1 February 4th, 2005 11:59 AM
Connecting to mySQL WIx ASP.NET 1.0 and 1.1 Basics 3 October 17th, 2004 04:13 PM
Connecting Access2000 to MySQL Database Rood67 Access 4 May 20th, 2004 12:49 PM

All times are GMT -4. The time now is 01:43 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.