Click here to Skip to main content
15,921,941 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi all

i have a datagridview, i want to save data thru stored procedure.

how i can check if the row is to update or insert command

example i have master detail, i have in detail data to edit , and i insert new line. i want to save them thru stored procedure , how can i check if the row as edit or new inserted one.

thanks in advance

ahmad zrein
Posted
Comments
AshishChaudha 13-Aug-12 2:24am    
What you have tried so far...please share what you have done, so help you better.
ahmad zrein 13-Aug-12 12:05pm    
i tried most commands update datset it does not work. i am using foreach datarow in dgv_ and send data to sql database , but i do not know is the row is to use update or insert command. or some thing i do not know, i need to read more.
ahmad zrein 13-Aug-12 15:29pm    
private void BindDataGridView()
{
try
{
dataset.Locale = System.Globalization.CultureInfo.InvariantCulture;

sqldaParent = new SqlDataAdapter(selectQueryStringAcc_TransParent, clsConnectionAcc.con);
SqlCommandBuilder sqlcbParent = new SqlCommandBuilder(sqldaParent);
sqldaParent.Fill(dataset, "acc_TransParent");

sqldaChild = new SqlDataAdapter(selectQueryStringAcc_TransChild, clsConnectionAcc.con);
sqldaChild.Fill(dataset, "acc_TransChild");

// Establish a relationship between the two tables.
DataRelation relation = new DataRelation("TransParentChild",
dataset.Tables["acc_TransParent"].Columns["iLedgerID"],
dataset.Tables["acc_TransChild"].Columns["iLedgerID"]);
dataset.Relations.Add(relation);

bsParent.DataSource = dataset;
bsParent.DataMember = "acc_TransParent";

bsChild.DataSource = bsParent;
bsChild.DataMember = "TransParentChild";
}
catch (SqlException)
{
MessageBox.Show("Connection is not established");
}
}

i want to update the master detail dataset

1 solution

C#
foreach (DataRow row in dataset.Tables["acc_TransChild"].Rows)
{
    MessageBox.Show(row.RowState.ToString());
}
 
Share this answer
 

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