Visual FoxPro Developer Center >
Visual FoxPro Forums
>
Visual FoxPro General
>
Need to start learning how to connect to an SQL database from VFP
Need to start learning how to connect to an SQL database from VFP
- I have never worked with an SQL database and will eventually need to tackle a project that needs to connect to one and extract data into a VFP table.The VFP 9 help assumes a higher level of knowledge that I have. Can anyone suggest how I should get started? Should I download MySQL or SQL Lite? Some suggested reading, samples or tutorials?Thanks
Dick Day
Answers
- IF You want to Use MySQL then first Install MySQL and MySQL ODBC Driver.you can start with from following command..lcConnStr = "DRIVER={MySQL ODBC 3.51 Driver}" +;";SERVER=" + lcSvrName +;";DATABASE=" + lcDbName +;";UID=" + lcDbUsrId +;";PWD=" + lcDbPwd +;";OPTION=530"gnConnHandle = Sqlstringconnect(lcConnStr)If gnConnHandle < 0lcMsg = 'Cannot establish connection to SQL Server.'Messagebox(lcMsg,16,'SQL Server Connect Error')glQuit = .T.Else* Some Code here as per your requirement* you can use SQLEXEC command for get data from tableEndif
Please "Mark as Answer" if this post answered your question. :)
Kalpesh Chhatrala | Software Developer | Rajkot | India
Kalpesh's Blog- Marked As Answer byDickDay Wednesday, November 04, 2009 9:45 AM
All Replies
- IF You want to Use MySQL then first Install MySQL and MySQL ODBC Driver.you can start with from following command..lcConnStr = "DRIVER={MySQL ODBC 3.51 Driver}" +;";SERVER=" + lcSvrName +;";DATABASE=" + lcDbName +;";UID=" + lcDbUsrId +;";PWD=" + lcDbPwd +;";OPTION=530"gnConnHandle = Sqlstringconnect(lcConnStr)If gnConnHandle < 0lcMsg = 'Cannot establish connection to SQL Server.'Messagebox(lcMsg,16,'SQL Server Connect Error')glQuit = .T.Else* Some Code here as per your requirement* you can use SQLEXEC command for get data from tableEndif
Please "Mark as Answer" if this post answered your question. :)
Kalpesh Chhatrala | Software Developer | Rajkot | India
Kalpesh's Blog- Marked As Answer byDickDay Wednesday, November 04, 2009 9:45 AM
- Kalpesh, thank you for such a quick, and easy answer :) I will begin experimenting with your example, thank you.
Dick Day The first thing you need to answer is, which SQL Database will you be using? MySQL, SQL Server, Oracle? Once you answer that, we can help you better.
Craig Berntson MCSD, Visual FoxPro MVP www.craigberntson.com- Ultimately, I need to connect to an SQL Server database. It will be some time before that database is available, so I thought I would start by learning on one of the smaller ones, hoping I could glean enough from my experience to help me with the SQL database.Is the syntax different enough that this approach would not work?Thanks,
Dick Day


