Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

ASP.NET Insert into database using stored procedure

Posted on 2007-11-16
3
Medium Priority
?
6,723 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 2000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Screencast - Getting to Know the Pipeline
Suggested Courses

927 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