Adding more than 1 column using insert

6 views
Skip to first unread message

tuffcode

unread,
Sep 17, 2009, 4:13:55 PM9/17/09
to asp-ajaxed
First off, thanks for making this fantastic library. Sincerely.

I am new to ajaxed but not classic ASP. I've just written a bit of
code to add a record to a MS SQL table using db.insert. Its great for
adding one column of data at a time. I would like to insert several
columns at once. Do I have to return the ID of the row just added then
use db.update severl times to update one column at a time? This seems
quite inefficient.

My simple table has 3 columns : user, date_added, and added_by

Here's an example of what is working...
<code>
page.return(db.insert("mydata.dbo.users", array("user",newuser)))
<code>

Id like to be able to add the user, date_added, and added_by values
all at once using a single db.insert. Does that make sense?

Iuri

unread,
Sep 17, 2009, 6:11:24 PM9/17/09
to tuffcode, asp-ajaxed
The second parameter is an array with (column, value) pairs, and you can put another columns and values in this parameter:

db.insert("your_table", array("user", newuser, "date_added", "NOW()", added_by, another_user))


[]s
iurisilvio

tuffcode

unread,
Sep 18, 2009, 7:25:47 PM9/18/09
to asp-ajaxed
Thanks! Works perfectly.
> > all at once using a single db.insert. Does that make sense?- Hide quoted text -
>
> - Show quoted text -
Reply all
Reply to author
Forward
0 new messages