Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL Insert fields with a ' in them
Message
From
02/06/2015 16:08:50
John Ryan
Captain-Cooker Appreciation Society
Taumata Whakatangi ..., New Zealand
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Desktop
Miscellaneous
Thread ID:
01620334
Message ID:
01620536
Views:
80
Mark,

If you want an easy way to do this: use a Remote View against the target SQL Table. If it's a one-off conversion you can create a temporary DBC and a SELECT * View against the target table in about a minute. Then use the View Designer's Properties to ensure field types are correct and make all fields updateable. Then simply Append or Replace from the VFP table into the view and watch the correct values turning up in the target table.

One thing to watch for: TEXT or TEXT BINARY fields sometimes get expressed by the View Designer as General fields rather than Memo or Memo (binary), and BIT fields should be Logical fields in the view. Properties lets you set the Field type correctly and you're good to go. Even with the largest table you're looking at a few minutes to get the RV set up supported by a few lines of code in most cases, or a simple APPEND if you've maintained table structure.

Because the RV creates a proper parameterized Insert, presence of ' in fields is of no concern and tricky datetime conversions for SPT for some databases are not problems you need to solve. It's also SQL Injection-proof if you end up having to supply the solution to customers and a DBC with its RV can be included in an exe.
"... They ne'er cared for us
yet: suffer us to famish, and their store-houses
crammed with grain; make edicts for usury, to
support usurers; repeal daily any wholesome act
established against the rich, and provide more
piercing statutes daily, to chain up and restrain
the poor. If the wars eat us not up, they will; and
there's all the love they bear us.
"
-- Shakespeare: Coriolanus, Act 1, scene 1
Previous
Reply
Map
View

Click here to load this message in the networking platform