Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to create INSERT with datetime type field?
Message
De
20/03/2007 10:42:25
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Versions des environnements
Visual FoxPro:
VFP 9
Divers
Thread ID:
01042503
Message ID:
01206078
Vues:
43
>>Naomi,
>>What I am trying to say is, this is the recommended way for any backend (be it VFP, SQL server, Oracle,Access ...).
>>If you do conversions yourself and put converted character value in command you might gain nanoseconds but then you have to know what each type of backend expects to see (for VFP you need {}, SQL server and many backends ODBC canonical format etc). With parametric approach you don't have to think about conversion. You can simply pass a date or datetime to both SQL server and Access with ?m.myDateOrDateTimeParameter.
>>Cetin
>
>I agree with that you're saying. My only problem is that I'm not 100% convinced that Access is "smart enough" to do the necessary implicit conversion by itself. That's why I need someone to quickly try it, since I received an e-mail saying this approach didn't work and then did some research on the topic. I probably need to ask to install Access here fore me.
>
> http://tek-tips.com/viewthread.cfm?qid=1266090
>http://tek-tips.com/viewthread.cfm?qid=545746#postform

You sent irrelevant links (2nd wouldn't work as it exactly does the opposite of what I'm saying).
So you were looking for a tester. OK I just tested this for you and it worked:
ldStart = {^1996/08/01}
ldEnd = {^1996/08/31}

lcMDBDir = 'C:\Program Files\Microsoft Office\Office11\samples'
lcMDBName = 'NORTHWIND.MDB'
lnConnHandle = SQLSTRINGCONNECT('DSN=MS Access Database;DBQ='+;
  lcMDBDir+'\'+lcMDBName+';DefaultDir='+;
  lcMDBDir+';DriverId=25;FIL=MS Access;MaxBufferSize=2048;'+;
  'PageTimeout=5;UID=admin;')

myDate = DATE()
*lcSQL = "select * from [Orders] where [RequiredDate] between ?ldStart and ?ldEnd"
lcSQL = "insert into [Orders] ([orderid],[RequiredDate]) values (39999,?m.myDate)"
? SQLExec(m.lnConnHandle, m.lcSQL)

lcSQL = "select * from [Orders]"
? SQLExec(lnConnHandle, lcSQL, 'MyResult')
SQLDisconnect(lnConnHandle)
SELECT myResult
browse
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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform