Click here to Skip to main content
12,951,619 members (64,306 online)
Rate this:
Please Sign up or sign in to vote.
See more:
Actually i am having a webform for fee-structure like below
fee-type |amount |annual/month(checkbox)
registration-fee: | textbox1| chekbox1
tution-fee: | textbox2 | checkbox2
books-fee |textbox3 |checkbox3

think that above is a form for fee-structure while clicking on the save button i want to save the records into below table manner

table fee-structure
1002 | registration-fee |1001 | 1(if checked means)
1002 | tution-fee | 2500 | 0(if not checked means)
1002 | books-fee | 2300 | 1

//my question is for inserting every record i have to take separate query...if not how i can write...i am giving my code below
 SqlCommand cmdInsertFeeQuotation = DBManager.DataAccess.command();
                    cmdInsertFeeQuotation.Parameters.Add(new SqlParameter("@option", SqlDbType.VarChar, 50));
                    cmdInsertFeeQuotation.Parameters["@option"].Value = "InsertFeeQuotation";
                    cmdInsertFeeQuotation.Parameters.Add(new SqlParameter("@Fee_Type", SqlDbType.VarChar, 50));
                    cmdInsertFeeQuotation.Parameters["@Fee_Type"].Value = "Registration Fee";
                    cmdInsertFeeQuotation.Parameters.Add(new SqlParameter("@Amount", SqlDbType.Money));
                    cmdInsertFeeQuotation.Parameters["@Amount"].Value = txtRegistrationFee.Text;
                    if (ckboxRegistrationFee.Checked == true)
                        cmdInsertFeeQuotation.Parameters.Add(new SqlParameter("@Annual_Month", SqlDbType.Bit));
                        cmdInsertFeeQuotation.Parameters["@Annual_Month"].Value = 1;
                        cmdInsertFeeQuotation.Parameters.Add(new SqlParameter("@Annual_Month", SqlDbType.Bit));
                        cmdInsertFeeQuotation.Parameters["@Annual_Month"].Value = 0;
                    string sqlquery1 = "SchoolProc";
                    DBManager.DataAccess.executeQuery(sqlquery1);//above code is for inserting one record but i want to inser three records at a time...
Posted 25-Feb-13 21:28pm
Updated 25-Feb-13 23:28pm
Rate this: bad
Please Sign up or sign in to vote.

Solution 3

for inserting more than one record at same time you use this technique.
Add your record in a datatable and insert record with single insert statement.[^][]
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

you have to create array of the text box for inserting multiple record at one time save click.
ntitish 26-Feb-13 4:13am
sir at the same time i want to save the checkbox values and fee-type also into table ...
ntitish 26-Feb-13 4:31am
how to save in array list sir...can u send me code for that if possible....
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

try using Table valued functions in SQL Server and use the following statement for ex:

INSERT INTO TestTable (FirstName, LastName)
SELECT FirstName, LastName

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

    Print Answers RSS
Top Experts
Last 24hrsThis month
OriginalGriff 6,229
CHill60 3,490
Maciej Los 3,083
Jochen Arndt 1,975
ppolymorphe 1,880

Advertise | Privacy | Mobile
Web01 | 2.8.170525.1 | Last Updated 26 Feb 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100