Hi
I want when i enter data in datagridview cell then that store or insert in database table
Datagridview data store in database table
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Pravin GhadgeRank #1,340 · 1.3K reputationPosted Dec 17, 2011, 12:30 AM EST
1)Use Row_added event of datagridview
2)In this event,Write Code of inserting record in database
shubhangi khandale55 reputationPosted Dec 17, 2011, 12:36 AM EST
but how to add records which is enter in cell.
using cell class this records insert in datagridview only not in database table
Pravin GhadgeRank #1,340 · 1.3K reputationPosted Dec 17, 2011, 12:44 AM EST
u can use
Row_Added event:
if(datagridview.row.count>0)
{
da = new SqlDataAdapter();
DataRow vDr;
da.SelectCommand = new SqlCommand();
da.SelectCommand.CommandType = CommandType.Text;
vCmBld = new SqlCommandBuilder(da);
da.SelectCommand.Connection = con;
da.SelectCommand.CommandText = "Select * from tablname";
da.Fill(vDs, "GradeDGV");
vDr = vDs.Tables["GradeDGV_PAYMENT"].NewRow();
vDr["SrNo"] = dataGridView1.Rows[datagridvew.rows.count].Cells["SrNo"].Value;
//specifed ur column name
vDs.Tables["GradeDGV"].Rows.Add(vDr);
da.Update(vDs, "GradeDGV");
vDs.Dispose();
da.Dispose();
}