Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

ASP.NET Insert into database using stored procedure

Posted on 2007-11-16
3
Medium Priority
?
6,721 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

722 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