Please Help

Results 1 to 2 of 2

Thread: Please Help

  1. #1
    Join Date
    Dec 1969

    Default Please Help

    I have a form to update certain records in a table from a database. However, some records are empty and therefore return an error that record not found. How do I code a way to have the form do an "Insert" into a table instead of an "Update" when a record isn't found and of course do a normal "Update" when there is a record.

  2. #2
    Nils Bilhorn Guest

    Default RE: Please Help

    If you use the execute method of a connection object there is a parameter that returns the number of rows affected by the statement, i.e. if that value is zero nothing was updated and you can do an insert instead.<BR><BR> connect.execute "update t set c = " & c & _<BR> " where k = " & k ,rows,128<BR> if rows = 0 then<BR> connect.execute "insert into t values(" & _<BR> k & "," & c),,128<BR> end if<BR><BR>or you can check beforehand by selecting the value<BR><BR> set rs = connect.execute("select 1 from t where k = " & k)<BR> if rs.eof then<BR> &#039;insert<BR> else<BR> &#039;update<BR> end if <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