Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to create INSERT with datetime type field?
Message
From
22/08/2005 08:52:33
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 9
Miscellaneous
Thread ID:
01042503
Message ID:
01042640
Views:
34
>Cetin,
>
>>Why are you trying to create such a string in the first place? Is it a cursoradapter or SQLExec() string? If so you better use parametric insert. ie:
>>
>>cInsertCommand = "insert into mytable (mydtfld) values (?m.ltDatetime)"
>>m.ltDatetime = datetime()
>>SQLExec(m.lnHandle, m.cInsertCommand)
>>
>
>I am trying to create a 3-tier application where the UI tier passes an array of field/value pairs to the Data Access tier. Then in the Data Access tier I need to update database, either VFP or SQL Server. So I am experimenting with different approaches. I use SQLExec for the SQL Server, by the way, not a cursoradapter. So, for the VFP database, I was building this long string of fields and values. I am trying to make the routine somewhat generic, that's why I was building the Insert string in the Data Access tier.
>
>If you see that I am not on the right track with this approach, please let me know. Thank you.

For SQL server see the parametric approach. It also handles headaches for conversion if field on VFP side is either date or datetime. ie:
* f1: char, f2: datetime, f3:datetime
cInsertCmd = "insert into myTable (f1, f2, f3) values (?m.Value1, ?m.Value2, ?m.Value3)"
SQLPrepare(m.lnHandle,m.cInsertCmd)
m.ldStart=date()
for ix=1 to 5
  m.Value1 = cdow(m.ldStart+m.ix-1)
  m.VAlue2 = m.ldStart + m.ix - 1
  m.Value3 = datetime() - (m.ix * 3600) 
  SQLExec(m.lnHandle)
endfor
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