Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > Pro VB Databases
| 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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #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

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

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