Hi,
i have tried to insert all rows at one time from datagridview c# into a table in database , although the table gets all the rows from datagridview but it always gets the values of the last row from datagridview for all the other rows , so all the rows in the table have the same values . Could anyone help ?
//class Presentation
for(int i=0; i<datagridview1.Rows.Count - 1; i++)
{
ClassPro.ProductA = datagridview1.Row.Cells[0].Value.ToString();
ClassPro.ProductB = datagridview1.Row.Cells[1].Value.ToString();
MyArray.Add(ClassPro);
}
//class Database Access Object
for(int i=0; i<Class.MyArray.Count; i++)
{
string InsertTable = "insert into table_name values('" + Class.MyArray.ProductA + "', '" + Class.MyArray.ProductB + "' )" ;
}