Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SQLEXEC - INSERT INTO syntax question
Message
 
À
31/12/2001 13:50:18
Cindy Winegarden
Duke University Medical Center
Durham, Caroline du Nord, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00599449
Message ID:
00599477
Vues:
21
Thanks for your assistance Cindy - and all the best to you in the New Year!

Al

>Allan,
>
>Do yourself a favor and use the "[" and "]" delimiters as you build your strSQL. For numbers, just don't use quotes. For dates, different SQL databases use different methods. One way is to just pass in a VFP date value. Another is to use "DATE(yyyy, mm, dd)".
>
>lcText = "One"
>lcText1 = "Two"
>lcNumber = "123.456"
>ldDate = {^2001/12/31}
>lcDate = [DATE(] + ;
>    TRANSFORM(YEAR(ldDate)) + [, ] + ;
>    TRANSFORM(MONTH(ldDate)) + [, ] + ;
>    TRANSFORM(DAY(ldDate)) + [) ]
>
>strSQL =
>    [Insert into tblTest(cText1, cText2, nNumber, dDate1, dDate2) ] + ;
>    [Values( ] + ;
>    ['] + (lcText) + [', ] + ;
>    ['] + (lcText1) + [', ] + ;
>    lcNumber + [, ] + ;
>    ldDate + [, ] + lcDate + [)]
>
>
>>Hi,
>>
>>I'm new to using VFP with SQL Server and I have a question about inserting records into a SQL Server database.
>>
>>I am using the SQLEXEC command to do inserts right now. So far, the only fields I've updated have been character fields. The way I'm doing this is creating a string named 'strSQL' and building the insert command - then running SQLEXEC to insert the record.
>>
>>For example:
>>
>>lcText = "One"
>>lcText1 = "Two"
>>
>>strSQL = "Insert into tblTest(cText1, cText2) Values( "
>>strSQL = strSQL + "'" + (lcText) + "', "
>>strSQL = strSQL + "'" + (lcText1) + "'" + ")"
>>
>>lcSuccess = SQLEXEC(gnSQLSwitchParsingConn,strSQL)
>>
>>Now, I want to do the same thing with datetime and numeric fields. How would I handle inserting records with those data types using SQLEXEC?
Al Williams

Anola MB, CANADA
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform