473,394 Members | 1,700 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

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 7003
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*********@hotmail.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_ServerClick(object sender, System.EventArgs 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++) {
oleDbInsertCommand2.Parameters["SomeD"].Value = tippings[i, 0];
oleDbInsertCommand2.Parameters["SomeValue"].Value = tippings[i, 1];
oleDbInsertCommand2.Parameters["SomeOtherValue"].Value = tippings[i, 2];
oleDbConnection1.Open();
oleDbInsertCommand2.ExecuteNonQuery();
oleDbConnection1.Close();
}
}

SSP

"SSP" <ss*@dt.com> wrote in message
news:OW**************@TK2MSFTNGP12.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.ToString() ].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****************@TK2MSFTNGP11.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_ServerClick(object sender, System.EventArgs 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++) {
oleDbInsertCommand2.Parameters["SomeD"].Value = tippings[i, 0];
oleDbInsertCommand2.Parameters["SomeValue"].Value = tippings[i, 1];
oleDbInsertCommand2.Parameters["SomeOtherValue"].Value = tippings[i, 2]; oleDbConnection1.Open();
oleDbInsertCommand2.ExecuteNonQuery();
oleDbConnection1.Close();
}
}

SSP

"SSP" <ss*@dt.com> wrote in message
news:OW**************@TK2MSFTNGP12.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%"
AutoGenerateColumns="False" DataMember="Table" DataKeyField="GameID"
DataSource="<%# dsMatchesForTipping1 %>" ForeColor="Black" GridLines="None"
CellPadding="2" BackColor="LightGoldenrodYellow" BorderWidth="0px"
BorderColor="Tan">
<Columns>
<asp:TemplateColumn SortExpression="GameID">
<ItemTemplate>
<input type="hidden" runat="server" name="GameID" id="GameID" value='<%#
DataBinder.Eval(Container.DataItem, "GameID") %>' />
</ItemTemplate>
</asp:TemplateColumn>

<asp:BoundColumn DataField="Date" SortExpression="Date" HeaderText="Date"
DataFormatString="{0:d MMM, yy}" />
<asp:BoundColumn DataField="Time" SortExpression="Time" HeaderText="Time"
DataFormatString="{0:t}" />
<asp:BoundColumn DataField="HomeTeamName" SortExpression="HomeTeamName"
HeaderText="Home Team" />
<asp:TemplateColumn SortExpression="HomeTeamID">
<ItemTemplate>
<INPUT id="radioButtonPickHomeTeam" runat="server" type="radio" value='<%#
DataBinder.Eval(Container.DataItem, "HomeTeamID") %>' name="Pick">
</ItemTemplate>
</asp:TemplateColumn>

<asp:BoundColumn DataField="VisitingTeamName"
SortExpression="VisitingTeamName" HeaderText="Visiting Team" />

<asp:TemplateColumn SortExpression="VisitingTeamID">
<ItemTemplate>
<INPUT id="radioButtonPickVisitingTeam" runat="server" type="radio"
value='<%# DataBinder.Eval(Container.DataItem, "VisitingTeamID") %>'
name="Pick">
</ItemTemplate>
</asp:TemplateColumn>

<asp:TemplateColumn HeaderText="Tie">
<ItemTemplate>
<INPUT id="radioButtonPickTie" runat="server" type="radio" value="Tie"
name="Pick">
</ItemTemplate>
</asp:TemplateColumn>

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

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

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

for (int i = 0; i <= tippings.Rank; i++) {
oleDbInsertCommand2.Parameters["GameID"].Value = tippings[i, 0];
oleDbInsertCommand2.Parameters["Pick"].Value = tippings[i, 1];
oleDbInsertCommand2.Parameters["Username"].Value = tippings[i, 2];
oleDbConnection1.Open();
oleDbInsertCommand2.ExecuteNonQuery();
oleDbConnection1.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.odedodea.edu> wrote in message
news:uK**************@TK2MSFTNGP10.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.ToString() ].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
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,...
9
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,...
12
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...
2
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...
4
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...
2
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,...
4
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...
4
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...
58
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...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.