Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Apr 2004
    Posts
    80
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Updating Access Database via asp form

    I am trying to create a processing script to update information froma form into a certain row via id number. I have the form set up to send the title, description, and id (as a private field) I just cant get it to process. I think my problem is my sql statement. Can you all have a look?

    PHP Code:
    <%
    Dim newidnewtitlenewdescriptiondata_sourceconStrSql

    ' A Function to check if some field entered by user is empty
    Function ChkString(string)
    If string = "" Then string = " "
    ChkString = Replace(string, "'", "''")
    End Function

    ' Receiving values from Form
    newid = ChkString(Request.Form("
    id"))
    newtitle = ChkString(Request.Form("
    title"))
    newdescription = ChkString(Request.Form("
    description"))
    data_source = "
    Provider=Microsoft.Jet.OLEDB.4.0Data Source=" & _ 
    Server.MapPath("
    ---")
    StrSql = "
    UPDATE calendar SET title '" & newtitle & "'description '" & newdescription & "' WHERE id #" & newid & "#"

    ' Creating Connection Object and opening the database
    Set con = Server.CreateObject("ADODB.Connection")
    con.Open data_source
    con.Execute StrSql

    DoneClose the connection
    con
    .Close
    Set con 
    Nothing

    Response
    .Redirect "confirmation.htm"
    %> 
    My rows are named id, title, and description, same with my form fields

  • #2
    Regular Coder
    Join Date
    Jul 2004
    Posts
    101
    Thanks
    0
    Thanked 0 Times in 0 Posts
    If newid is a autonumber or number datatype, sql statement should be:

    WHERE [id] = & newid

    Try and see because numbers datatype should not be in quotes.

  • #3
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,037
    Thanks
    0
    Thanked 250 Times in 246 Posts
    Quote Originally Posted by needhelp26
    If newid is a autonumber or number datatype, sql statement should be:

    WHERE [id] = & newid

    Try and see because numbers datatype should not be in quotes.
    If it's indeed a number, then it should be:

    StrSql = "UPDATE ... WHERE id=" & newid

  • #4
    Regular Coder
    Join Date
    Jul 2004
    Posts
    101
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thankyou again. I always find my ways thru trial and error.


  •  

    Posting Permissions

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