SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    May 2003
    Location
    Austin,TX
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    inserting/updating database

    I am using ASP with MySQL. This is code for a calendar application that saves info to the database based on date. It is not giving an error when processed. Nothing is being inserted into the database and nothing is being updated either. Can anyone help?

    Dim vDate
    Dim chkTxt
    Dim DiaryID
    vDate = request("view_date")

    Call OpenDB()
    ' Check to see if it's a new record to be added or an old one to update
    StrSql= "Select * from diary where dte = '$vDate'"
    set rs = DbConn.Execute (StrSql)
    chkTxt = chkString(request("txt"))

    if rs.BOF or rs.EOF then ' No records found. i.e. New record
    StrSql ="INSERT INTO diary (dte, text_field) values ('" & vDate & "','" & chkTxt & "')"
    else ' Record found. i.e. update record.
    DiaryID = rs("id")
    StrSql = "UPDATE diary SET diary.dte = '$vDate', text_field = '$chkTxt' WHERE id = '$DiaryID'"
    End If

    DbConn.Execute (strSql)

    Also, I have verified that VDate shows a correct date but it only is entered as 0000-00-00 in the database. Should I use timestamp if time is not necessary?

  2. #2
    Sultan of Ping jofa's Avatar
    Join Date
    Mar 2002
    Location
    SvÝ■jˇ­
    Posts
    4,080
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    StrSql= "Select * from diary where dte = '$vDate'"

    looks more like php than asp

    Should be
    StrSql= "Select * from diary where dte = '" & vDate & "'"


Bookmarks

Posting Permissions

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