Hello,
I have a Datagridview which has a combobox,and 2 textbox, The combobox is bound to a Datasource(Data base Sql Server and the table name is Category)
,and Datagridview is not bounded to any datasource. When the user selects an item in the combobox,and enters the item(text) in the 2 text box , I want all the 3(combobox selected item, and the entered text in the 2 textbox) of them to store it a a table name called Transact_tablet rialone.(column s for Transact_tablet rialone are categoryname, description,amo unt)
I am using a stored procedure and the code below
When I try this code, and check my Database , the value "False" is stored in the column description and for the amount 0.0000 is always stored.
Thanks a lot for the help.
-S
I have a Datagridview which has a combobox,and 2 textbox, The combobox is bound to a Datasource(Data base Sql Server and the table name is Category)
,and Datagridview is not bounded to any datasource. When the user selects an item in the combobox,and enters the item(text) in the 2 text box , I want all the 3(combobox selected item, and the entered text in the 2 textbox) of them to store it a a table name called Transact_tablet rialone.(column s for Transact_tablet rialone are categoryname, description,amo unt)
I am using a stored procedure and the code below
Code:
void savetotransact_table() { //SqlDataAdapter TransactDataAdapter = new SqlDataAdapter(new SqlCommand("SELECT description,amount FROM Transact_table", connection)); SqlDataAdapter TransactDataAdapter = new SqlDataAdapter(new SqlCommand("SELECT * FROM Transact_tabletrialone", connection)); cDS.Clear(); TransactDataAdapter.Fill(cDS, "Transact_tabletrialone"); DataRow cOrderRow = cDS.Tables["Transact_tabletrialone"].NewRow();//name of the table ,and rowobject cOrderRow["categoryname"] = dataGridView1.Columns[0].Selected; cOrderRow["description"] = dataGridView1.Columns[1].Selected; //dataGridView1.Rows[dataGridView1.CurrentRow];//name of the column cOrderRow["amount"] = dataGridView1.Columns[2].Selected;//dataGridView1.Columns[2].HeaderText; // cOrderRow["categoryid"] = cDS.Tables["Transact_tabletrialone"].Rows.Add(cOrderRow); TransactDataAdapter.InsertCommand = new SqlCommand("databaseinserttransacttrial",connection); SqlCommand cmdInsert = TransactDataAdapter.InsertCommand; cmdInsert.CommandType = CommandType.StoredProcedure; // cmdInsert.Parameters.Add(new SqlParameter("@categoryid", SqlDbType.Int, 50, listCol.)); cmdInsert.Parameters.Add(new SqlParameter("categoryname", SqlDbType.VarChar, 50, "categoryname")); cmdInsert.Parameters.Add(new SqlParameter("@description", SqlDbType.VarChar, 50, "description")); cmdInsert.Parameters.Add(new SqlParameter("@amount", SqlDbType.Money, 50,"amount")); TransactDataAdapter.Update(cDS, "Transact_tabletrialone"); // cmdInsert.ExecuteNonQuery(); // binddatagridview(); }
Thanks a lot for the help.
-S
Comment