Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL Pass Through Problem
Message
From
31/10/2005 10:54:31
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
01063586
Message ID:
01063594
Views:
11
>I'm trying to form an INSERT INTO string and run it:
>
>
>sSqlCommand = "insert into syserrors "+;
>  "(datetime, error, line, message, codeline, program," +;
>  "user, appname, memory, status, callstack, notified)"+;
>  " values "+;
>  "("+ sDateTime + "," +;
>  sErrNo + "," +;
>  sLineNo + "," +;
>  "'" + sErrMessage + "' ," +;
>  "'" + sLineOfCode + "' ," +;
>  "'" + sProgram + "' ," +;
>  "'" + sUserId + "' ," +;
>  "'" + sAppName + "' ," +;
>  "'" + sMemory + "' ," +;
>  "'" + sStatus + "' ," +;
>  "'" + sStack + "' ," +;
>"0)"
>
>
>After running this the string looks like:
>
>
>insert into syserrors (datetime, error, line, message, codeline, program, user, appname,
>memory, status, callstack, notified)
>values
>(10/31/2005 07:40:27,1000,5000,'TEST MESSAGE' ,'TEST CODE LINE' ,'TEST PROGRAM' ,'KMAROIS'
>,'TEST' ,'' ,'' ,'TEST STACK' ,0)
>
>
>
>SQL Server is returning the error "Incorrect syntax near '07'.
>
>Notice the DateTime value. It seems to be appearing as a string. Anyone know how
>to solve this?

Use parametric strings.
text to m.sSqlCommand noshow
insert into syserrors 
  (datetime, error, line, message, codeline, program,  
  user, appname, memory, status, callstack, notified)
   values 
  (?m.sDateTime,?m.sErrNo ,?m.sLineNo, ?m.sErrMessage,... )
endtext

sDatetime = {^2005/10/31 07:40:27}
sErrno = 1000
sLineNo = 5000
...

SQLExec(m.lnHandle, m.sSQLCommand)
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform