Using Update, Insert, and InsertUdate

11 views
Skip to first unread message

SteveMets

unread,
Jun 24, 2009, 12:44:21 PM6/24/09
to asp-ajaxed
Hi,

I'm trying to use one of the Database methods, in this case Update.
What I want to do is have this function run when I Submit the form.
I'm not sure how to write the function, where on the form to place it,
and how to call it from the submit button. Also, I have my form
method set to GET so I can get a value from the query string- will
this affect it?

Thanks

Michal Gabrukiewicz

unread,
Jun 24, 2009, 12:50:00 PM6/24/09
to SteveMets, asp-ajaxed
create a normal form with a submit button and put the following code in your main()

sub main()
  if page.isPostback() then
    yourvalue = page.QS("yourFormFieldName")
    db.update("tablename", array("dbColumnName", yourvalue), "yourIDYouWantToUpdate"
  end if
end sub
--
michal

SteveMets

unread,
Jun 24, 2009, 1:13:55 PM6/24/09
to asp-ajaxed
I have tried this in main():

if page.isPostback() then
updated = db.update("RegForm", array("ContactPhone", "225-888-6666"),
738)
'str.writef("Updated {0} records", updated)
else
... do other stuff
end if

I am passing in static values to keep it simple. The page posts back,
all data fields are cleared, but the data field in the table remains
unchanged. Also, the str.write gives me an error about 'not using
parentheses in sub ', so I had to comment it out.
I'd like to redirect to a success page.; but first it has to update
the record

On Jun 24, 11:50 am, Michal Gabrukiewicz <mga...@gmail.com> wrote:
> create a normal form with a submit button and put the following code in your
> main()
>
> sub main()
>   if page.isPostback() then
>     yourvalue = page.QS("yourFormFieldName")
>     db.update("tablename", array("dbColumnName", yourvalue),
> "yourIDYouWantToUpdate"
>   end if
> end sub
>

SteveMets

unread,
Jun 24, 2009, 2:11:12 PM6/24/09
to asp-ajaxed
Michal,

as I said in my orig. post, I was wondering if "GET" would affect the
update. It does actually prevent the post; changing it to "POST"
does the trick. Now if I can get Validations working- do you put the
validations in Main() as well? Before the update or insert? Thanks

On Jun 24, 11:50 am, Michal Gabrukiewicz <mga...@gmail.com> wrote:
> create a normal form with a submit button and put the following code in your
> main()
>
> sub main()
>   if page.isPostback() then
>     yourvalue = page.QS("yourFormFieldName")
>     db.update("tablename", array("dbColumnName", yourvalue),
> "yourIDYouWantToUpdate"
>   end if
> end sub
>

Michal Gabrukiewicz

unread,
Jun 24, 2009, 10:15:22 PM6/24/09
to asp-ajaxed
the update should work fine ...not sure what is happening ..


if the error says you should leave out the parenthesis then i would do it ;)
check this article
http://www.webdevbros.net/2009/06/16/read-error-messages-understand-them-and-write-your-own/
--
michal
Reply all
Reply to author
Forward
0 new messages