Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Data update in SQL Server
Message
From
25/11/2006 15:20:05
 
 
To
24/11/2006 10:05:15
General information
Forum:
Visual FoxPro
Category:
Client/server
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Database:
MS SQL Server
Miscellaneous
Thread ID:
01172264
Message ID:
01172426
Views:
16
This message has been marked as a message which has helped to the initial question of the thread.
Hi,

use parameters markers instead.

e.g.
lcSQL = 'UPDATE yourTable SET field1 = ?yourVariable1, field2 = ?yourVariable2 WHERE primary_key = ?yourPK'
?SQLEXEC(lnConnection,lcSQL)
there are several advantages to this approach:
-the SQL statement will be fixed lenght and does not depent on the data beeing send
-the SQL statement cannot be invalidated by the data beeing sent, with your current approach when a variable contains a ' character for example the SQL statement is no longer valid (variable content: "St' something" - SQL: SET someField = 'St' something')
-you don't have to deal with the datatype conversions, FoxPro knows howto correctly pass parameters in a SQL statement

Regards
Christian
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform