If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Connecting to MySQL with Visual FoxPro

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-10-07, 11:19
CharlieDenver CharlieDenver is offline
Registered User
 
Join Date: Aug 2007
Posts: 4
Question 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 ?
Reply With Quote
  #2 (permalink)  
Old 08-10-07, 21:39
tod.mckenna tod.mckenna is offline
Registered User
 
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.
__________________
Tod means Fox :: Follow me on Twitter
Reply With Quote
  #3 (permalink)  
Old 08-11-07, 05:27
CharlieDenver CharlieDenver is offline
Registered User
 
Join Date: Aug 2007
Posts: 4
MySQL - VFP

Thanks Tod
I will let you know how I get on
Phillip
Reply With Quote
  #4 (permalink)  
Old 08-15-07, 07:19
CharlieDenver CharlieDenver is offline
Registered User
 
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
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On