473,738 Members | 5,084 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How would I insert multiple rows of data from one form?

SSP
Dear ASP.NETers,

How would I insert multiple rows of data from a web form?

Are there any tute's and stuff around. Couldn't find any myself.

Thanks in advance.
SSP
Nov 17 '05 #1
5 7038
Hi SSP,

Yes, you can insert multiple rows of data from a webform.
simply call sproc, how many number of times you want to
insert data.

HTH

Ravikanth

-----Original Message-----
Dear ASP.NETers,

How would I insert multiple rows of data from a web form?

Are there any tute's and stuff around. Couldn't find any myself.
Thanks in advance.
SSP
.

Nov 17 '05 #2
SSP
Hi Ravikanth,

I can't use sproc's unfortunately.

I am using ACCESS 2000 database.

Any other methods?

SSP

"Ravikanth[MVP]" <dv*********@ho tmail.com> wrote in message
news:0a******** *************** *****@phx.gbl.. .
Hi SSP,

Yes, you can insert multiple rows of data from a webform.
simply call sproc, how many number of times you want to
insert data.

HTH

Ravikanth

-----Original Message-----
Dear ASP.NETers,

How would I insert multiple rows of data from a web form?

Are there any tute's and stuff around. Couldn't find any

myself.

Thanks in advance.
SSP
.

Nov 17 '05 #3
SSP
I am half way there to figuring it out.

So far I have managed to write the following code to insert an array into
the database.

Now I have to figure out how to get the relevant DataList fields into an
array (to insert into the database). Any ideas on creating a dynamic array.

Code:

private void Submit1_ServerC lick(object sender, System.EventArg s e)
{
// Create an Array
string[,] tippings = new string[,] {{"988", "AUS", "hhhty"}, {"56678",
"SA", "LfghghjLL" }, {"2367673", "NZ", "dfdfghgfjgfhf" }};
// Loop through the Array and insert one by one.
for (int i = 0; i <= tippings.Rank; i++) {
oleDbInsertComm and2.Parameters["SomeD"].Value = tippings[i, 0];
oleDbInsertComm and2.Parameters["SomeValue"].Value = tippings[i, 1];
oleDbInsertComm and2.Parameters["SomeOtherValue "].Value = tippings[i, 2];
oleDbConnection 1.Open();
oleDbInsertComm and2.ExecuteNon Query();
oleDbConnection 1.Close();
}
}

SSP

"SSP" <ss*@dt.com> wrote in message
news:OW******** ******@TK2MSFTN GP12.phx.gbl...
Dear ASP.NETers,

How would I insert multiple rows of data from a web form?

Are there any tute's and stuff around. Couldn't find any myself.

Thanks in advance.
SSP

Nov 17 '05 #4
I'm not sure if I'm answering the question you are asking, but if you need
to create a dynamic array (to replace the static dummy array "string[,]
tippings") that is pretty simple:

name the all your input fields for each row the same (using a numerical
sequence for each extra row), when you submit, use something like:

// for loop
string[] row = Request.Form[ strPrefix +
iRowName.ToStri ng() ].ToString.Split (", ");
AddRowToDB( row );
//end for loop

It would be a whole lot easier to do this using a DataGrid, DataSet,
DataAdapter, and relative Commands for the DataAdapter.

// Mike

"SSP" <ss*@dt.com> wrote in message
news:%2******** ********@TK2MSF TNGP11.phx.gbl. ..
I am half way there to figuring it out.

So far I have managed to write the following code to insert an array into
the database.

Now I have to figure out how to get the relevant DataList fields into an
array (to insert into the database). Any ideas on creating a dynamic array.
Code:

private void Submit1_ServerC lick(object sender, System.EventArg s e)
{
// Create an Array
string[,] tippings = new string[,] {{"988", "AUS", "hhhty"}, {"56678",
"SA", "LfghghjLL" }, {"2367673", "NZ", "dfdfghgfjgfhf" }};
// Loop through the Array and insert one by one.
for (int i = 0; i <= tippings.Rank; i++) {
oleDbInsertComm and2.Parameters["SomeD"].Value = tippings[i, 0];
oleDbInsertComm and2.Parameters["SomeValue"].Value = tippings[i, 1];
oleDbInsertComm and2.Parameters["SomeOtherValue "].Value = tippings[i, 2]; oleDbConnection 1.Open();
oleDbInsertComm and2.ExecuteNon Query();
oleDbConnection 1.Close();
}
}

SSP

"SSP" <ss*@dt.com> wrote in message
news:OW******** ******@TK2MSFTN GP12.phx.gbl...
Dear ASP.NETers,

How would I insert multiple rows of data from a web form?

Are there any tute's and stuff around. Couldn't find any myself.

Thanks in advance.
SSP


Nov 17 '05 #5
SSP
OK I tried and I can't still manage it.

Here's the full scenario:
What I am building is a footy tipping (pool) competition app. What I am
trying to do is to allow lots of people to tip the winning team from a list
of games to be played every week. This schematic shoulf give an idea of the
tipping form:

Tipping Form


Date Time Home Team Visiting Team Tie
2 Aug, 03 7:00 PM England Fiji
2 Aug, 03 7:00 PM Fiji Australia
2 Aug, 03 7:00 PM New Zealand Australia




This is the datagrid my ASPX Page:
-------------------------------------------------------------------
<asp:datagrid id=DataGrid1 runat="server" Width="100%"
AutoGenerateCol umns="False" DataMember="Tab le" DataKeyField="G ameID"
DataSource="<%# dsMatchesForTip ping1 %>" ForeColor="Blac k" GridLines="None "
CellPadding="2" BackColor="Ligh tGoldenrodYello w" BorderWidth="0p x"
BorderColor="Ta n">
<Columns>
<asp:TemplateCo lumn SortExpression= "GameID">
<ItemTemplate >
<input type="hidden" runat="server" name="GameID" id="GameID" value='<%#
DataBinder.Eval (Container.Data Item, "GameID") %>' />
</ItemTemplate>
</asp:TemplateCol umn>

<asp:BoundColum n DataField="Date " SortExpression= "Date" HeaderText="Dat e"
DataFormatStrin g="{0:d MMM, yy}" />
<asp:BoundColum n DataField="Time " SortExpression= "Time" HeaderText="Tim e"
DataFormatStrin g="{0:t}" />
<asp:BoundColum n DataField="Home TeamName" SortExpression= "HomeTeamNa me"
HeaderText="Hom e Team" />
<asp:TemplateCo lumn SortExpression= "HomeTeamID ">
<ItemTemplate >
<INPUT id="radioButton PickHomeTeam" runat="server" type="radio" value='<%#
DataBinder.Eval (Container.Data Item, "HomeTeamID ") %>' name="Pick">
</ItemTemplate>
</asp:TemplateCol umn>

<asp:BoundColum n DataField="Visi tingTeamName"
SortExpression= "VisitingTeamNa me" HeaderText="Vis iting Team" />

<asp:TemplateCo lumn SortExpression= "VisitingTeamID ">
<ItemTemplate >
<INPUT id="radioButton PickVisitingTea m" runat="server" type="radio"
value='<%# DataBinder.Eval (Container.Data Item, "VisitingTeamID ") %>'
name="Pick">
</ItemTemplate>
</asp:TemplateCol umn>

<asp:TemplateCo lumn HeaderText="Tie ">
<ItemTemplate >
<INPUT id="radioButton PickTie" runat="server" type="radio" value="Tie"
name="Pick">
</ItemTemplate>
</asp:TemplateCol umn>

<asp:TemplateCo lumn SortExpression= "UserEmail" >
<ItemTemplate >
<input type="hidden" runat="server" name="UserEmail " id="UserEmail"
value="ss*@ssp. com" />
</ItemTemplate>
</asp:TemplateCol umn>

</Columns>
</asp:datagrid>
----------------------------------------------------------------------------
----

For the Code Behind Page:
----------------------------------------------------------------------------
------
private void Submit1_ServerC lick(object sender, System.EventArg s e)
{
string[,] tippings = new string[,] {{"988", "AUS", "hhhty"}, {"56678",
"SA", "LfghghjLL" }, {"2367673", "NZ", "dfdfghgfjgfhf" }};

for (int i = 0; i <= tippings.Rank; i++) {
oleDbInsertComm and2.Parameters["GameID"].Value = tippings[i, 0];
oleDbInsertComm and2.Parameters["Pick"].Value = tippings[i, 1];
oleDbInsertComm and2.Parameters["Username"].Value = tippings[i, 2];
oleDbConnection 1.Open();
oleDbInsertComm and2.ExecuteNon Query();
oleDbConnection 1.Close();
}
}
----------------------------------------------------------------------------
----------

Basically, if I am able to insert in the database the array "tippings"; then
I should be able to dynamically populate the "tippings" array and then
insert it into the database.

Unfortunately I am unable to do it ;-( and time isn't on my side either.

Any ideas?

SSP

"Mike S" <mi***@n-o.sp-a.m.pac.odedode a.edu> wrote in message
news:uK******** ******@TK2MSFTN GP10.phx.gbl...
I'm not sure if I'm answering the question you are asking, but if you need
to create a dynamic array (to replace the static dummy array "string[,]
tippings") that is pretty simple:

name the all your input fields for each row the same (using a numerical
sequence for each extra row), when you submit, use something like:

// for loop
string[] row = Request.Form[ strPrefix +
iRowName.ToStri ng() ].ToString.Split (", ");
AddRowToDB( row );
//end for loop

It would be a whole lot easier to do this using a DataGrid, DataSet,
DataAdapter, and relative Commands for the DataAdapter.

// Mike

Nov 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
5520
by: Sans Spam | last post by:
Greetings! I have a table that contains all of the function permissions within a given application. These functions are different sections of a site and each has its own permissions (READ, WRITE, UPDATE, DELETE) which are controlled by a web frontend and the table records are manipulated to control the permissions. Example: The Press Release section record would look like this: Username: John Doe Function Name: Press Release
9
3459
by: Martin | last post by:
Hello, I'm new with triggers and I can not find any good example on how to do the following: I have two tables WO and PM with the following fields: WO.WONUM, VARCHAR(10) WO.PMNUM, VARCHAR(10) WO.PROBLEMCODE, VARCHAR(8)
12
3011
by: shank | last post by:
I'm trying to use online samples for submitting multiple records from ASP into a stored procedure. Failing! Through the below form, a user could be submitting many records at a time. I'm not getting any records inserted. For troubleshooting, I cut the form down to 1 textbox and when submitted it populated 5 rows of the same data. So I know I'm connected, but not getting the LOOP and NEXT correct? How do I set this up so many records can be...
2
3681
by: wombat53 | last post by:
Hi Group Are there any DB2 UDB ESE DPF V8.2 users exploiting "buffered inserts" (BIND parm INSERT BUF) *and* "multi-row INSERTS" (many rows associated with the VALUES clause of the INSERT to minimize number of calls to the RDMBS engine) in an SQL PL Stored Procedure? I ask, as the latter would imply embedded DYNAMIC SQL due to potentially varying number of rows to be inserted (assume it's varying), and so, the SQL INSERT would have be...
4
2916
by: Michel Esber | last post by:
Hello, Environment: db2 V8 FP 13 LUW Our application currently uses: insert into table values ('A'),('B'),...('Z') We have used CLI arrays inserts (1000 array and commit size) and managed to insert 1 Million rows into an empty table in 32 seconds. Our
2
7052
by: assgar | last post by:
Hi Developemnt on win2003 server. Final server will be linux Apache,Mysql and PHP is being used. I use 2 scripts(form and process). The form displays multiple dynamic rows with chechboxs, input box for units of service, description of the service and each row has its own dropdown list of unit fees that apply. Each dynamically created row will return 3 values fee1_choice, fee1_unit and fee1_money. Note The above informaton is...
4
4862
by: =?Utf-8?B?UmljaA==?= | last post by:
On a form - I have a datagridview which is docked to the entire form. The datagridview allows users to Delete and/or Add Rows. On the Form_Load event I Fill the datagridview source table with a sql DataAdapter (da) da.SelectCommand.CommandText = "Select * from Servertbl1" da.Fill(ds, "tbl1") so far, so good. If I add a row to the datagridview I use the following sqlDataAdapter code to update the server table - which works OK when...
4
5657
by: edtrvl | last post by:
Hi there, I'm trying to insert multiple rows from a table format web form into multiple rows in a SQL table, (1 row for 1 row). Any help would be greatly appreciated, thanks in advance Here's the code of my page: <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%> <!--#include file="../../../Connections/BILLING.asp" --> <% FEQUIPID = Request.form("EQUIPID") ' Convert the info from the form to a string
58
8113
by: bonneylake | last post by:
Hey Everyone, Well recently i been inserting multiple fields for a section in my form called "serial". Well now i am trying to insert multiple fields for the not only the serial section but also the parts section an i seem to be having trouble. When i try to insert into the parts section i get the error Invalid character value for cast specification. But not sure what i am doing wrong. Here is what i am using to insert. All the sections...
0
8968
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9473
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9259
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8208
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6053
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4569
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4824
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3279
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2193
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.