Solved

ASP.NET Insert into database using stored procedure

Posted on 2007-11-16
3
6,717 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
ID: 20304000
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
ID: 20306960
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
ID: 31409710
I wrote it 5 times in the end. Thanks for your help
0

Featured Post

ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…

825 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