Click to See Complete Forum and Search --> : ADO/RDO connection to server for a mysql db


Sopok
April 9th, 2001, 02:24 AM
Hi ,

I am currently involved in a project using vb6 and mysql . I have an local application which i want to connect to a database on the server , I would like to know how to connect a local database to database on server using vb.

sotoasty
April 9th, 2001, 08:43 AM
First you will need to download the ODBC drivers for mySQL. They can be found here.

http://www.mysql.com/downloads/api-myodbc.html

Next you will need to set up a DSN for the database. I used a System DSN and configured it like...

Windows DSN name (anything you like)
MySQL Host (Server Name or IP)
MySQL Database Name (The Name of your Database)

Add your Username and Password and you should be ready to go.

Hope this helps

Sopok
April 10th, 2001, 09:29 PM
Thanx but i've done all those things and stil couldn't access the database. When I try to a mesage with an adodc headline saying that i can't access the server/computer/database comes out. Any ideas?

sotoasty
April 11th, 2001, 07:00 AM
Have you tried your ODBC connection with any other Application? In fact, in VB6, you can use the data manager to see if you can connect to the database. Also, depending on setup, the database/tables may be case sensitive. The data manager can definately help in building the form or getting the correct Connection String. Here is some short code showing you how to do this using RDO 2.0



public TC as RDO.rdoConnection
public TR as RDO.rdoResultset
public TQ as RDO.rdoQuery
private Sub Form_Load()

set TC = new rdoConnection
set TQ = new RDO.rdoQuery
TC.Connect = "DSN=PlaceDSNNameHere;DB=PlaceDatabaseNameHere;SERVER=PlaceServerNameHere;UID=PlaceUserIDHere;PWD=PlacePassWordHere;PORT=;option=0;STMT=;"
TC.CursorDriver = rdUseOdbc
TC.EstablishConnection
TQ.SQL = "SELECT * FROM Employees;" ' Select all from Employees Table
set TQ.ActiveConnection = TC
TQ.Execute
set TR = TQ.OpenResultset(rdOpenForwardOnly, rdConcurReadOnly)
TR.MoveNext
Debug.print TR!LastName
TR.Close
TQ.Close
TC.Close
End Sub





Hope this helps!