first of all ,i will thank you for reading this . :-)
i am writing a programming to access SQL-SERVER.
i use some codes as follows in order to update data changed in datagrid1.
but i found that it dose not work with a table without primary key.
How can i solve this problem ?
************************************************** *************************
codes:
sqlCMD.CommandText = "SELECT * FROM mytable";
sqlDA.SelectCommand = sqlCMD;
SqlCommandBuilder cmdBuilder = new SqlCommandBuilder(sqlDA);
SqlCommandBuilder cmdBuilderEx = new SqlCommandBuilder(sqlDA);
sqlDA.UpdateCommand.Connection = sqlCon;
sqlDA.InsertCommand.Connection = sqlCon;
sqlDA.UpdateCommand = cmdBuilder.GetUpdateCommand();
sqlDA.InsertCommand = cmdBuilderEx.GetInsertCommand();
dataGrid1.DataSource = dataSet2.Tables[0];
sqlDA.Update(dataSet2);