Send a date value to my database

Results 1 to 2 of 2

Thread: Send a date value to my database

  1. #1
    Join Date
    Dec 1969

    Default Send a date value to my database

    I created a cookie to hold the time a user logs in. Later I want to write the log-in time and the time a certain procedure is run to my Oracle database.<BR>If I use <BR><BR> log_conx = Server.CreateObject("ADODB.Connection");<BR> log_conx.Open(MM_Maps_con_STRING);<BR> up_log_rs = Server.CreateObject("ADODB.Recordset");<BR> up_log_qry = "SELECT TIME_IN FROM P_ACTIVITY WHERE 0=1";<BR> up_log_rs.Open(up_log_qry,log_conx,1,3,1);<BR> up_log_rs.AddNew;<BR> /* TIME_IN is a date value column in the db<BR> up_log_rs("TIME_IN")= Request.Cookies("timein"); <BR> up_log_rs.Update;<BR><BR>the line <BR> up_log_rs("TIME_IN")= Request.Cookies("timein");<BR> <BR>returns a type mismatch error. But if I use<BR><BR> rsUserLog("TIME_IN") = Date.parse(Request.Cookies("timein"));<BR><BR>it returns a out of present range error.<BR><BR>I need to A) pass my cookie value as a date understood by the ADO Recordset object<BR> or B) let the number of seconds be passed but in a type large enough to hold it<BR> <BR>What do you think and how do I do this?

  2. #2
    Join Date
    Dec 1969

    Default JS is bad with dates...

    It has problems producing Date values that are compatible with COM interfaces, and ADODB.RecordSet is a COM component.<BR><BR>I&#039;d suggest using a SQL UPDATE instead...<BR><BR>log_conx = Server.CreateObject("ADODB.Connection");<BR>log_co nx.Open(MM_Maps_con_STRING);<BR>up_log_qry = "INSERT INTO P_ACTIVITY (TIME_IN) VALUES(&#039;" & theTime & "&#039;)"<BR>log_conx.Execute(up_log_qry);<BR><BR> You&#039;ll need to manipulate that Request.Cookies value to produce a date/time string that Oracle will accept, but at least that&#039;s just string manipulation stuff.<BR><BR>Just incidentally, this will probably perform 3 to 10 times better than the AddNew stuff, anyway.<BR><BR>********<BR><BR>I just saw a *MAJOR* error! Two of them, actually:<BR><BR> up_log_rs.AddNew;<BR> up_log_rs.Update;<BR><BR>If you think those are invoking the AddNew and Update methods, you are sadly mistaken. They are just getting the *addresses* of those methods and then tossing them away.<BR><BR> up_log_rs.AddNew[hl="yellow"]( )[/hl];<BR> up_log_rs.Update[hl="yellow"]( )[/hl];<BR><BR>JS *never* calls functions if you don&#039;t provide the parens.<BR><BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts