If Statement

Results 1 to 2 of 2

Thread: If Statement

  1. #1
    Navtej Singh Guest

    Default If Statement

    I am updating a record in a database only if the user inputs data to be updated. (They will be show the current record data, and if they want to update it, they will enter the new data in a text box)<BR><BR>I thought I should be using an If statement (if textbox is greater than "", update the record, or else leave it alone)<BR><BR>What should my If statements look like? (if i should be using If statements!)

  2. #2
    Join Date
    Dec 1969

    Default you can do this:

    u have ur data in &#060;td&#062;s in a table which i hope is inside a form, so when u hit "submit", next page:<BR>if request("txtname") &#060;&#062; "" then<BR>sql = "update tablename set fieldname = &#039;" & request("txtname") & "&#039; where primarykeyfield = " & request("primarykeyvalue")<BR>set rs = conn.execute(sql)<BR>end if<BR>&#062;&#062;request("primarykeyvalue") is the unique field value that you will show in the table while showing the record to the user first time or u can just keep it hidden if u want withing the form.<BR>&#062;&#062;Also you might not even use the If statement, just use the sql, even if the user hasnt filled the text box then also it wont make a difference, sql will just update the record once again but of course this will mean unnecessary trip to the server, oh well u better use the sql, I just gave u both the scenario.<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