Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. articles. downloads. faq. members. files. rss.
 From: Pete Sass
  Where is Pete Sass?
 Marathon, Ontario
 Canada
 Pete Sass
 To: Rajesh Halyal
  Where is Rajesh Halyal?
 SANGLI
 India
 Rajesh Halyal
Subject: RE: how to create a string of values that can be used to insert in SQL server
Thread ID: 110551 Message ID: 110590 # Views: 1 # Ratings: 1
Version: Visual FoxPro 6 Category: Databases, Tables and SQL Server
Date: Friday, October 20, 2006 2:14:26 PM         
   



> I am trying to create a string depending on the cursor fields & its
> type to be used to pass it to insert command for SQL server.
> I am having 2 problems
> 1> How to include character fields with quotes, square brackets & other
> special characters.
> 2> How to send date fields.
> -----------------------------------
> Rajesh Halyal



Hi,
Please read my thread: http://www.foxite.com/archives/0000108058.htm
In this I have the generic code for both INSERT and UPDATE, and the
UPDATE string is only added to the update syntax if in fact the
field value has been changed.
The INSERT function does exactly what you want it to do and that
is generically dynamically build a field list and a value list
based upon a local VFP cursor that was created via a SQL-Select
statement against a SQL-Server backend table.
You will notice in the source code the correct conversions have been
made to the strings to hamdle; character, datetime, integer, decimal,
and memo fields.
You will see within the same threads the a DELETE function is also
shown two threads below the thread identified above.
I coded this as I was just sick and tired of entering in large field
and value strings with SQL-Server backend table with many tables
containing over 70-80 fields.
Using generic functions like this will save you a lot of hours in
typo errors and frustration.
Pete from the Great White North. (Only in Canada, ay.) Over and Out ...

ENTIRE THREAD