Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2007
    Posts
    4

    Question Unanswered: Connecting to MySQL with Visual FoxPro

    Hello, I wondered if anyone could help
    I have a MySQL database that is hosted on a UNIX server on the internet
    I wanted to connect to it with Visual FoxPro Vr 8 from a Windows PC
    Is this possible, How do I set VFP up to do this ?

  2. #2
    Join Date
    Jul 2007
    Location
    Belgium
    Posts
    15
    You sure can. You'll need to have the MySQL ODBC 3.51 Driver installed on the Window's machine, and your UNIX server will need to be set up to allow your IP address to connect. If you have cPanel, you can set up your IP as an 'Access Host'. If you don't, you may need to contact your provider. Here is some basic code:

    Code:
    lcServer="your_server_ip_address"   && IP Address of server
    lcDatabase="database_name"
    lcUser = "user_name"
    lcPassword = "password"
    lcStringConn="Driver={MySQL ODBC 3.51 Driver}"+;
                 ";Server="+lcServer+;
                 ";Database="+lcDatabase+;
                 ";Uid="+lcUser+;
                 ";Pwd="+lcPassWord
    
    *-- Don't prompt for login
    SQLSETPROP(0,"DispLogin",3)
    lnHandle=SQLSTRINGCONNECT(lcStringConn)
    
    IF lnHandle  > 0
       	*-- open connection, get the data, then close the connection
       	
       	lcSQL = "SELECT * FROM sometable"
       	
       	SQLEXEC(lnHandle, lcSQL ,"crTemp")
       	SQLDISCONNECT(lnHandle)
       	
       	SELECT crTemp
       	LOCATE
       	BROWSE NORMAL NOWAIT
    	
    ELSE
       	=AERROR(laError)
       	MESSAGEBOX("Error at Connecting"+CHR(13)+;
                   "Description:"+laError[2])
    ENDIF
    I don't have VFP8 installed on my local PC, but I believe this should work just fine. The ability to connect to remote databases through SQL Passthrough has been around in VFP for a while! Let me know if you have any problems.

    You can also check out OpenTech. There is a forum called "Using VFP with MySQL" that could give you a lot more info. I also post mySQL and VFP related content on my blog.

  3. #3
    Join Date
    Aug 2007
    Posts
    4

    MySQL - VFP

    Thanks Tod
    I will let you know how I get on
    Phillip

  4. #4
    Join Date
    Aug 2007
    Posts
    4

    Tunnel

    Hi,
    I set this up and I can't connect, having spoken to the Hosting people, they inform me I need to use a http tunnel. do you know what this means, or if VFP is compatible with this requirement

Posting Permissions

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