Solved

ASP.NET Insert into database using stored procedure

Posted on 2007-11-16
3
6,715 Views
Last Modified: 2010-04-21
Hi Experts,

(using DW CS3, I know its no good but please bear with me)

I have a form that I have created with up to 5 rows of information

Firstname,Surname,DOB etc
Firstname2,Surname2,DOB2 etc
Firstname3,Surname3,DOB3 etc
Firstname4,Surname4,DOB4  etc
Firstname5,Surname5,DOB5 etc

When I submit to "add.aspx" I have the following code snippet.

What is the code syntax to add all 5 lots of data into the same stored procedure?

Can I simply copy and paste the code 5 times and change the Request.Form names?

Thanks experts.

 


<%@ Page Language="VB" ContentType="text/html" ResponseEncoding="utf-8"  AutoEventWireup="false" %>

<%@ Register TagPrefix="MM" Namespace="DreamweaverCtrls" Assembly="DreamweaverCtrls,version=1.0.0.0,publicKeyToken=836f606ede05d46a,culture=neutral" %>

<MM:DataSet

runat="Server"

id="Procedure1"

IsStoredProcedure="true"

CreateDataSet="false"

ConnectionString='<%# System.Configuration.ConfigurationSettings.AppSettings("MM_CONNECTION_STRING_LINKS02") %>'

DatabaseType='<%# System.Configuration.ConfigurationSettings.AppSettings("MM_CONNECTION_DATABASETYPE_LINKS02") %>'

CommandText="dbo.ASP_CLS_InsertUpdateStudent"
 

Debug="true"

>

<Parameters>

    <Parameter  Name="@RETURN_VALUE"   Type="Integer"   Direction="ReturnValue" />

    <Parameter  Name="@responsiblePersonID"  Value='<%# IIf((Request.Form("RespID") <> Nothing), Request.Form("RespID"), "0") %>'  Type="Integer"   Direction="Input" />

    <Parameter  Name="@personID"  Value='<%# IIf((Request.Form("personID") <> Nothing), Request.Form("personID"), "-1") %>'  Type="Integer"   Direction="Input" />

    <Parameter  Name="@givenNames"  Value='<%# IIf((Request.Form("FirstName") <> Nothing), Request.Form("FirstName"), "") %>'  Type="VarChar"   Direction="Input" />

    <Parameter  Name="@surname"  Value='<%# IIf((Request.Form("Surname") <> Nothing), Request.Form("Surname"), "") %>'  Type="VarChar"   Direction="Input" />

    <Parameter  Name="@dateOfBirth"  Value='<%# IIf((Request.Form("DateOfBirth") <> Nothing), Request.Form("DateOfBirth"), "") %>'  Type="DBTimeStamp"   Direction="Input" />

    <Parameter  Name="@gender"  Value='<%# IIf((Request.Form("Male") <> Nothing), Request.Form("Male"), "") %>'  Type="VarChar"   Direction="Input" />

    <Parameter  Name="@Email"  Value='<%# IIf((Request.Form("Email") <> Nothing), Request.Form("Email"), "") %>'  Type="VarChar"   Direction="Input" />

    <Parameter  Name="@DateLastUpdated"  Value='<%# IIf((Request.Form("DateLastUpdated") <> Nothing), Request.Form("DateLastUpdated"), "") %>'  Type="DBTimeStamp"   Direction="Input" />

  </Parameters>

</MM:DataSet>

<MM:PageBind runat="server" PostBackBind="true" />

Open in new window

0
Comment
Question by:nikdonovanau
3 Comments
 
LVL 22

Accepted Solution

by:
DarkoLord earned 500 total points
Comment Utility
Hi,

with (ordinary) stored procedures, you can only submit one lot of data at a time - usually you have call the stored procedure once for each row, or make the stored procedure accept parameters for all rows at once, which would be highly impractical if there were more than few rows to insert at once.

Regards,
Darko
0
 
LVL 12

Expert Comment

by:Mortaza Doulaty
Comment Utility
Hi,

As DarkoLord said, you have to submit each row once for that stored procedure.
Or you can write an other stored procedure that has five insert into statement and parameters for each field of each row.
0
 
LVL 1

Author Closing Comment

by:nikdonovanau
Comment Utility
I wrote it 5 times in the end. Thanks for your help
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video discusses moving either the default database or any database to a new volume.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now