Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 24th, 2004, 03:11 PM
Authorized User
 
Join Date: May 2004
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to Seb_soum
Default Multiple Insert.....any ideas?

Hi guys

I need to insert multiple fields. Let say 20 Text boxes displayed on a page, but only 10 get filled in. I need to ignore the empty ones and insert only the ones with something on them. Also, how do I insert multiple items into a DB....eg

txt1 into tblName , txt2 into tblPostcode, txt3 into tblDate
txt4 into tblName , txt5 into tblPostcode, etc......

so far you guys have been awesome
 
Old May 24th, 2004, 07:11 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Hello,

If multiple insert statements exist, write out separate insert statements, and do: Connection.Execute(strSQL)

TO ignore the empty fields, either provide null for that field, or only insert the fields into the SQL string that exist, which you can do something like:

if ( txt5 <> "" ) then
  strParamSQL = strParamSQL & "Value, "
  strValueSQL = strValueSQL & "'" & txt5.text & "', "
end if

That way the values that exist only get's inserted. At the end, strip of the last ", " because that will cause problems, and call the execute method for the SQL as such:

Connection.Execute("insert into tblPostCode (" & strParamSQL & ") values (" & strValueSQL & ")"

I hope this is what you were looking for...

Brian
 
Old May 25th, 2004, 03:43 PM
Authorized User
 
Join Date: May 2004
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to Seb_soum
Default

WOOOAAAAHHHHHH!!!! bit complicated for me. Any ideas where I could find some tutorials on this? I really need the "Dummy's guide to ASP" kind of thing





Similar Threads
Thread Thread Starter Forum Replies Last Post
How t o insert multiple values qazi_nomi Access ASP 2 May 3rd, 2005 12:45 AM
Multiple Insert tsimsha Classic ASP Basics 1 January 19th, 2005 07:48 AM
Insert multiple records mateenmohd Access 13 November 2nd, 2004 09:15 AM
insert multiple records mateenmohd Classic ASP Basics 19 October 18th, 2004 01:22 AM
Multiple value insert mateenmohd SQL Server 2000 3 October 7th, 2003 12:55 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.