Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

connection string for connecting to mysql using vb 6?

Status
Not open for further replies.

keith23

Technical User
May 26, 2005
97
NL
Hi all. i am new to vb 6 world. I am trying to make an .exe application take user input and write it to external mysql database that recides in external server.

I be happy if an expert tell me what connection string should use to connect to mysql database which recides in external or local mysql database?Thanks


part of code that i wrote for connection to access db
Code:
Option Explicit
Private cn As ADODB.Connection 'this is the connection
Private rs As ADODB.Recordset 'this is the recordset


Private Sub Form_Load()
Me.MousePointer = 11 'this makes the mouse pointer the hourglass

[b]
    Set cn = New ADODB.Connection 'we've declared it as a ADODB connection lets set it.
    cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
      "Data Source= c:\my documents\DB1.mdb" 'this is the connection string
    cn.Open
    Set rs = New ADODB.Recordset 'as we did with the connection

[/b]
    rs.Open "tbl_master", cn, adOpenKeyset, adLockPessimistic, adCmdTable 'opening the recordset explained in the notes
       
rs.movefirst 'moves to the first record
Do Until rs.EOF = True 'this is the Loop to add items to the combo box
Combo1.AddItem rs.Fields("field1") 'this adds items from field1 into the combo box
rs.MoveNext 'moves next record
Loop
rs.movefirst
fillfields 

Me.MousePointer = 0 'sets the mouse pointer to the normal arrow
End Sub
 
You will also need the MySQL ODBC driver. It's available from:

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top