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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VFP and MySQL 1

Status
Not open for further replies.

slurpyx

Programmer
Aug 1, 2002
59
PH
Ok.. guys... im a newbie..

I'm Just toying with the idea of VFP with a MySQL backend. I've done some PHP and MYSQL, its safe to say that im fluent with MySQL.

I just want to know, the step by step procedure on how to connect vfp on mysql..

tnx.
 
Hy
I use MySQL with VFP and works great.

First of all you need a DNS connection.

On Win'98: Control Panel-ODBC Data Source-User DNS-Add-MySQL ODBC 3.51 Driver (here depend on your version).

After that in VFP you have 3 way to acces data.

1. To make a connection and a Remote View
2. With SQL Pass Through (very fast)
3. In VFP 8.0 with a new class CursorAdapter (very easy)

I allready made a class where I use SQL Pass Through.

I like MySQL more than MSQL and it is faster. I downloaded MYSQL 4.1.0-alpha that now suport subqery.

Sorry for my english I'm not a native :)

Liviu
 
Tnx for the reply, ive been looking over the web using google and its showing up thousands of links that really dont matrs... and of b4 i forget the english is undrsntdble :)

I already configured the ODBC portion.

But Can you kindly give me an example of your "Sql Pass Through", Im using Visual Fox Pro 6.0. If you dont mind.. a sample connection and a simple query of "Select * from sample;" will do.

Do you know of any links that i can download a simple VFP6.0 program that illustrates Insert, Update, Delete and Select statements of MySQL using VFP?

tnx a lot!
 
Tnx for the reply, ive been looking over the web using google and its showing up thousands of links that really dont matrs... and of b4 i forget the english is undrsntdble :)

I already configured the ODBC portion.

But Can you kindly give me an example of your "Sql Pass Through", Im using Visual Fox Pro 6.0. If you dont mind.. a sample connection and a simple query of "Select * from sample;" will do.

Do you know of any links that i can download a simple VFP6.0 program that illustrates Insert, Update, Delete and Select statements of MySQL using VFP?

tnx a lot!
 
Ok based on what you have you will need:

nConnection = Sqlstringconnect(sConnectionString)

...and:

nRowsReturned = SQLEXEC(nConnection,sSQLString,MyCursor)

As to links there is a decent article and some code for VFP to MYSQL sitting on Linux server out on Foxtalk if you are a subscriber (search site for "MYSQL"), other than that I haven't seen any.

Slighthaze = NULL
 
slurpyx

Tnx for the reply, ive been looking over the web using google and its showing up thousands of links that really dont matrs... and of b4 i forget the english is undrsntdble :)

Yes, but yours is barely understandable. This isn't a chat room, since a lot a members here are not fluent in English, you might consider using complete words.


Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
slurpyx,

You don't have to use a data source name to connect to MySQL. Try using a DSN-less connection in VFP like this example:
Code:
MyConnection = SQLSTRINGCONNECT("driver={MySQL}" + ;
     ";server=localhost;uid=myid;pwd=mypwd;database=mydatabase")
NumRows = SQLEXEC(MyConnection, 'select * from MyTable', 'MyCursor')

Make sure you have MYODBC installed in your computer.

HTH,

Medic
 
medic,

Nice post, I thought about walking slurpyx through getting the connection string, but was lazy and figured he already had a DNS set up...I usually set one up just so I can cut-n-paste the connection string (like I say I am lazy and can never remember the exact order of things and syntax). So anyways, appreciated your post.

Slighthaze = NULL
 
Wow! mom, I just received my first "star" ever since joining this forum! :-D
 
medic

Wow! mom, I just received my first "star" ever since joining this forum

[tt]I had to buy a new computer the first time I got a star (I dropped it)[/tt][party]

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
medic,

Your mom called and said that she was very very proud of you.

Mike,

Probably dropped that computer because of the shear weight of the stars it contained!

On a serious note (based on something Mike posted awhile back):
Stars have a tendency to be misused and/or not used sometimes. There are times when multiple forum members bust there behinds to solve a person's problem and not so much as a reply is written. There are times when faulty code or answers completely off topic get a star. It seems to be hit or miss somedays, half-baked code gets a star while pure genius receives dead silence. Now, like so much of my complaining here and at work I don't have an alternate solution to propose, so I think I will take myself back to the VFP IDE and write some more half-baked code. :eek:) Nice work medic!

Slighthaze = NULL
 
guys.. your ther bomb! i'll try it out! and ill keep you posted on what will happen..

again.. tnx!
 
slighthaze

Probably dropped that computer because of the shear weight of the stars it contained!

I should have done like Ramani, kept the AS-400 ;-)


Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Thank you Mike & Slighthaze. :~/

I've learned much from guys like you already, and it's just nice to realize I was able to contribute a "useful" post.

Incidentally, I was among those who happened to give stars to helpful posts I really appreciated (though sometimes the thread originators forgot to express their gratitude on whatever way). I was very sure those posts were of great help at least for me.

Sometimes, various factors affect the helpfulness of certain codes, like hardware, OS, system configuration, etc. What's applicable for my environment may not be for others.

Medic
 
Hey guys... again.. thank you very much...

i tried this:

MyConnection = SQLSTRINGCONNECT('dsn=mysql_connect')
NumRows = SQLEXEC(MyConnection, 'select * from sample01', 'sample')

ThisForm.Text1.value=sample.name

and it worked! i think i will expand from here.. :)

Now.. the grid.. is the problem.. do i have to this manually? i.e: sample.field ..etc etc.. ?
 
Hy again,

If you would to wait a while until the new version 8.0 will be on market this problem being solved by this new version using CursorAdapter class.

Otherwise you need to do this manually.

If you want I can send you a sample class that I made to connect on MySQL

Liviu

 
liviushiva

If you would to wait a while until the new version 8.0 will be on market this problem being solved by this new version using CursorAdapter class.

? It's been out for a few weeks now.

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
slurpyx,

if you can successfully create a dsn then you can use the connection string instead and forego having to have the dsn set up on whatever computer your application is running on. create a text file and rename it comething like "connstr.udl" then double-click the file, create your connection string, test connection and click OK when it is working, then open that udl file (Microsoft Data Link) in notepad and cut & paste the connection string out of it and use it instead. Just a thought, maybe you know the DSN will be available on the computers so no need.

Slighthaze = NULL
 
liviushiva, i would love to take a look on your class... i'm on the woods here.. and would really love to try out all the possible way to achive a good VFP and MySQL connection... Am using vfp 6.0

many thanks!
 
My e-mail address liviushiva@hotmail.com

I'm waiting for your e-mail and I'll send you my class. In the meantime I used very much cursadapter (VFP8.0) and I am delighted with this new class.

Liviu
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top