CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2001
    Location
    Sarawak,Malaysia
    Posts
    5

    ADO/RDO connection to server for a mysql db

    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.




  2. #2
    Join Date
    Sep 2000
    Location
    FL
    Posts
    1,452

    Re: ADO/RDO connection to server for a mysql db

    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



  3. #3
    Join Date
    Apr 2001
    Location
    Sarawak,Malaysia
    Posts
    5

    Re: ADO/RDO connection to server for a mysql db

    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?


  4. #4
    Join Date
    Sep 2000
    Location
    FL
    Posts
    1,452

    Re: ADO/RDO connection to server for a mysql db

    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!


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured