Click here to Skip to main content
15,892,517 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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
student_id|fee_type|amount(textbox)|annual/month(checkbox)
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
C#
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;
                   }
                   else
                   {
                       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
Updated 25-Feb-13 23:28pm
v4

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.
http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlbulkcopy.aspx[^][]
 
Share this answer
 
you have to create array of the text box for inserting multiple record at one time save click.
 
Share this answer
 
Comments
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....
try using Table valued functions in SQL Server and use the following statement for ex:

SQL
INSERT INTO TestTable (FirstName, LastName)
SELECT FirstName, LastName
 
Share this answer
 
v2

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900