Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQLEXEC - INSERT INTO syntax question
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00599449
Message ID:
00599478
Views:
27
Hi Larry,

Thanks for your suggestion. I'll look into what you've suggested.

Al

>Al,
>It's not. < s >
>
>The SQL Server ODBC driver has a property called AutoTranslate. This proeprty determines if SQL Server will translate character expressions into the appropriate data type if they don't match. For example, if the field in question is a date and the character string passed in matches the date format then it will be translated. The default for this property is Yes (things will be translated). However, if this is set to No in the ODBC entry or the connection string then your code will fail.
>
>A better approach, IMO, is to use the T-SQL function CONVERT() to explicitly convert your character string to the required date type. Ex.
>set textmerge on
>text to strSQL noshow
>   Insert into tblTest(cText1, cText2, nNumber1, tDatetime1) Values(
>      '<< lcText >>','<< lcText1 >>',<< lnNumber >>,
>      convert(datetime,'<< year(ltdt) >>/<< month(ltdt) >>/<< day(ltdt) >> << hour(ltdt) >>:<< minute(ltdt) >>:<< sec(ltdt) >>',120)
>endtext
(remove spaces before and after << >>)
>
>Style 120 equates to yyyy/mm/dd hh/mm/ss (24Hr clock).
>
>Also, in VFP 7, you can use the new TEXT TO Variable option. This makes programming SQL statements a lot easier because you don't have to worry about multiple delimiters ('"]) inside the string.
>
>HTH.
Al Williams

Anola MB, CANADA
Previous
Reply
Map
View

Click here to load this message in the networking platform