Solved

ASP.NET Insert into database using stored procedure

Posted on 2007-11-16
3
6,716 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

920 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

15 Experts available now in Live!

Get 1:1 Help Now