Results 1 to 5 of 5

Thread: Mysql In Visual Basic 6.0

  1. #1
    Join Date
    Feb 2009
    Posts
    43

    Mysql In Visual Basic 6.0

    hi,
    I would like to know how to connect the MySQL databse with visual basic?what is the simple code that connect visual basic and Mysql.Any recommendations and suggestions are appreciated.

  2. #2
    Join Date
    May 2008
    Posts
    2,389

    Re: Mysql In Visual Basic 6.0

    You need to download MyVbQL project, from Planet Source Code, and compile it into a dll, or include it directly in your project, and easily use it as a class...

    Library has 4 classes: MYSQL_CONNECTION -> Provides connectivity to MySQL server MYSQL_RS -> Provides access to recordsets(tables) within MySQL database MYSQL_FIELD -> Provides access to fields within MySQL table MYSQL_ERR -> Provides access to error object, to see if any MySQL errors occured You can access tables fields same as you would access a variable declared as a Collection: Recordset.Fields("fieldname").Value Recordset.Fields(fieldindex).Value As the library is open source, when you get the source code, you will see all the properties of all four classes in the project... I'd recommend downloading it from PSC.

  3. #3
    Join Date
    May 2008
    Posts
    2,012

    Re: Mysql In Visual Basic 6.0

    have you installed odbc driver 3.51. if not then download and install it. Then create a DSN from control panel-> administrartive tools -> data sources (ODBC). And then paste below code:

    Code:
    Dim sqlstr As String 
    Dim rs As ADODB.Recordset 
    Dim conn As ADODB.Connection 
    conn = New ADODB.Connection 
    rs = New ADODB.Recordset 
    conn.Open("DRIVER={MySQL ODBC 3.51 Driver};SERVER=localhost;DATABASE=urdatabasename;USER=ABC;PASSWORD=XYZ;OPTION=3;") 
    sqlstr = "select * from test_table" 
    rs.CursorLocation = ADODB.CursorLocationEnum.adUseClient 
    rs.Open(sqlstr, conn, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic) 
    MsgBox("success" & rs.RecordCount)

  4. #4
    Join Date
    Feb 2008
    Posts
    1,852

    Re: Mysql In Visual Basic 6.0

    use this:
    Code:
    dim con1 as new adodb.connection
    con1.CursorLocation = adUseClient
    con1.ConnectionString = "DRIVER={MySQL ODBC 3.51 Driver};SERVER=serverip;DATABASE=databasename;USER=usename;PASSWORD=pwd;;;"
    con1.Open
    then suppose u have table emp in ur dbase
    then 
    dim k as new adodb.recordset
    set k=new adodb.recordset
    k.open "select * from emp",con1,adopendynamic,adlockoptimistic
    use k recordset as you want,first set connection in odbc in control panel

  5. #5
    Join Date
    Apr 2008
    Posts
    2,005

    Re: Mysql In Visual Basic 6.0

    hi,
    you must have the driver that is used in connecting to mysql.

Similar Threads

  1. what are Visual Basic IDE?
    By Naresh Modi in forum Software Development
    Replies: 2
    Last Post: 06-03-2009, 09:49 AM
  2. Is GUI same like Visual Basic ?
    By Caesar in forum Software Development
    Replies: 2
    Last Post: 02-03-2009, 01:32 PM
  3. Visual Basic 2005 or Visual Basic 6
    By Aasha in forum Software Development
    Replies: 5
    Last Post: 15-01-2009, 06:56 PM
  4. Light remote visual fox pro to MySQL 5
    By Vincenzo in forum Software Development
    Replies: 1
    Last Post: 10-10-2008, 07:03 PM
  5. Visual Basic on LAN
    By djbbenn in forum Software Development
    Replies: 2
    Last Post: 05-08-2008, 02:15 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,235,092.16318 seconds with 17 queries