Home > Microsoft SQL Server > date problem

date problem



hi all...



here is my code



Set con = server.creteobject ("ADODB.Connection")

con.Open "mydb"



resultupdate = "INSERT INTO db (date) VALUES (#"&now()&"#)"



con.Execute resultupdate



But it give error -- Syntax error in INSERT INTO statement.



any idea??



thx

    
Guest


hi ieie,

I have several ideas about possible problems....



1, you misspelled crea teobject, i assume it was a misstyping here or something since you said you can connect



2, you don't specify a name/password in your code, generally annonymous browsing is disabled but if you've enabled it, have you enabled insert commands for that user? and if so, i'd recommend changing it and not doing it that way....



3, this looks like an access query, are you using msSQL server or access?

Was this answer helpful ? Yes No   
Guest


Use spaces to make your code readable. Will help you, as well.



INSERT INTO db (date) VALUES ('" & now() & "')"

Notice the single quotes

Access uses the # to indicate datetime values. I prefer passing a string. That works also for SQL Server and others

Was this answer helpful ? Yes No   
Guest
 
 
Home - About Infoqu - Contact - Privacy Statement - Link to Infoqu - Bookmark Infoqu

Copyright 2007-2008 by Infoqu. All rights reserved