Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I would like to know what the code

Status
Not open for further replies.

adamsoderqvist

Programmer
Sep 8, 2001
136
SE
I would like to know what the code to update a DB should look like, using the objConnection.Execute command!

This is what I have to ecxecute a delete task:

Code:
Dim strSQL
strSQL = "DELETE FROM tblArtiklar WHERE ArtID=" & Request.QueryString("ArtID")

'Execute...
objConn.Execute strSQL

objConn.Close
Set objRS = Nothing

...but what should the UPDATE syntax be, using SQL commands?
 
Update would look something like this:

strSQL = "UPDATE table SET column='" & value & "',"
strSQL = strSQL & " column='" & value & "'"
strSQL = strSQL & " WHERE column = '" & value & "'"

'Execute...
objConn.Execute strSQL


Remove the single quotes for values that are number types.
 
UPDATE table_name SET col1=value1, col2=value2, ...
WHERE [condition];
 
OK, when I run this:

Code:
strSQL = "UPDATE tblMember SET LastLogin=#" & Date() & "#, LoginTime='" & Time() & "' WHERE UserName= '" & strUserName & "'"

'Execute...
objConn.Execute strSQL

It works, BUT: the database sets the day as month, and the month as day resulting in that July 1st 2002 will be presented as January 7th 2002!! -Why is this? Could it have to do with the "#" signs? (they has to be there in one way or another...)

When I run the old code:

Code:
objRS("LastLogin") = Date()
objRS("LoginTime") = Time()
objRS.Update

...the date is returned/inserted into the DB, correctly.

What to do?
 
strSQL = "UPDATE tblMember SET LastLogin=#"& Date &"#, LoginTime=#"& Time &"# WHERE UserName='"& strUserName &"';"


Time is # also ! not « ' »
 
I know, tried that as well.... but no - doesn't work. The date is still messed up. Suggestions?
(Note that the "date-reversion" only occurs when I update using the UPDATE-command in SQL, not with "objRS.Update"!)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top