Update Syntax problem

Results 1 to 4 of 4

Thread: Update Syntax problem

  1. #1
    Christos Papadogoulas Guest

    Default Update Syntax problem

    I try to update my records in my access database, but i fail.<BR>Could you please tell me what is the proper syntax of an the update command taking into consideration , that i want to update also a &#039;date&#039; field in my database.<BR><BR>Thank you in advance.

  2. #2
    RobT Guest

    Default RE: Update Syntax problem


  3. #3
    Andres C. Guest

    Default RE: Update Syntax problem

    Using ASP:<BR>&#039;use CDate to convert a string to a valid date format<BR>myDate = CDate("10/10/01") &#039;or whatever date variable/string<BR><BR>SQL = "UPDATE mytable SET datefield = &#039;" & myDate & "&#039; WHERE anyfield = anycondition"<BR><BR>conn.Execute SQL<BR><BR>conn.close<BR><BR>If there&#039;s a chance that an invalid date will be passed, you can use IsDate(yourdatavariable) to test if it can be converted into a date before you call CDate. Otherwise, you would get an error, if the value passed to CDate can not be converted to a valid date.

  4. #4
    Join Date
    Dec 1969

    Default RE: Update Syntax problem

    Again I am not sure if this is a help but this code works for me.<BR><BR> &#060;%<BR> strConnection ="Provider=Microsoft.Jet.OLEDB.4.0;" & _<BR> "Data Source=" & Server.Mappath("database.mdb") &";" & _ <BR> "Jet OLEDB:Database Password=pass;"<BR> <BR> sql = " SELECT * FROM table WHERE ID=" & Request.QueryString("ID")<BR> <BR> Set objRec = Server.CreateObject("ADODB.Recordset")<BR> objRec.LockType = 3<BR><BR> objRec.Open sql,strConnection<BR><BR><BR> objRec("field_name").value = Update_value<BR> objRec.Update <BR>&#039; The .value stay that way it is. Say you were looking to up a <BR>&#039;feild name of ID. Then that line would look like this<BR>&#039; objRec("ID").value = "new value" <BR><BR><BR><BR> objRec.Close<BR> SET objRec = NOTHING<BR><BR> %&#062; <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