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

using the database

Status
Not open for further replies.

Octagon6

Programmer
Mar 18, 2003
18
US
Ok... I made the database for my program. But when I try and add sql statements in my code, I keep getting syntax errors. I'm a little confused here. Do I have to add code to communicate with the database, or does it do that automatically because it's all in the project manager section?
 
Octagon6

Database or tables? Database is a container that contains your tables.
But to open a database use:
open database myDatabase.dbc shared

To open a table:

USE myTable.dbf shared again in 0
SELECT myTable
browse
Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Octagon6,
What sort of syntax errors are you getting? Are you using the Query Designer? Are you writing you own SQL? Can you post some code that is giving you trouble? What version of VFP are you using? (VFP 8.0 has tightened up some of the syntax to make it more ANSI compatible.)

Rick
 
Mike's response is correct if you are accessing Foxpro tables with your SQL. For Foxpro, whether or not the tables are defined within a database container does not affect how you open them, except that you can specify a database container name in your USE statement, thus:

USE mydatabase!mytable shared

Also, remember that Foxpro (up through version 7 anyway) does not support all the SQL syntax that Client-Server databases like SQL Server or Oracle do - it only supports a sub-set of the standard SQL. Foxpro could return a syntax error if you use a syntax it doesn't support.

If you are accessing SQL Server or Oracle, you're probably going to do it through ODBC using SQLCONNECT() and SQLDISCONNECT() to connect, SQLEXEC() to run SQL against the database, and AERROR() to check for errors. To do this, you need an ODBC entry, which you create by from the Windows Control Panel.

Hope this helps. Mike Krausnick
 
I think I got it working now. My sql statements were a little messed up. I'll post again if I have anymore problems.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top