Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Help with vfp and SQL
Message
From
05/11/1997 10:38:47
John Baird
Coatesville, Pennsylvania, United States
 
 
To
05/11/1997 07:33:24
Bob Tracy
Independent Consultant
Driftwood, Texas, United States
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00058224
Message ID:
00058371
Views:
28
Turns out the problem is using " as a delimiter instead of ' for the lcStudentId. Thanks for your input and answer. >Can anyone tell me why this code is not returning any values from the Connection. If I use the Interactive SQL query program that comes with SQL 6.5, and give it [Select * from students where loginid="john"], the query returns the expected results. If I use the program below, gnConnHandle is a positive integer; however, lnResult is -1 and the query returns nothing. > >If I try this with lcSQL = "Select * from students" it works just fine. It seems that the where clause is causing the problem. What am I overlooking? Using vfp5.0, sql6.5, nt4.0 > >STORE SQLCONNECT('MyDataBase', 'sa') TO gnConnHandle >IF gnConnHandle <= 0 >RETURN >ENDIF > >lcStudentID='john' >lcPassword = 'n' >lcSessionId='' > >lcSQL = 'SELECT * FROM students WHERE Loginid="' + lcStudentID +'"' >lnResult = SQLEXEC(gnConnHandle, lcSQL, 'cStud') >SELE cStud >brow >IF _TALLY = 0 >**-- generate error >RETURN "Bad Student ID" >ENDIF John, I think the problem your're having is in substituting lcSQL in your lnResult statement. Try writing out the select in lnResult (lnResult = SQLEXEC(gnConnHandle,"SELECT * ......) and see if that works. You might also try macrosubstitution in the lcSQL statement: lcSQL = 'SELECT * FROM students WHERE Loginid = &lcStudentID' You might want to rewrite your select as a stored procedure in SQLSever and pass the student id as a parameter. I've found that stored procedures are a very fast way to run queries like yours and you don't have to worry about differences in syntax between the front end and back end. Good Luck!
Previous
Reply
Map
View

Click here to load this message in the networking platform