Hi all,
I'm currently make my final year project program at university, and have been puzzled by this problem for sometime now.
The issues I am having is that when I try to update a value in a specific column of a specif row. The program has a paddy and decides to fall over at *.
I am notified with the following message;
InvalidOperationException was unhandled
Dynamic SQL generation for the UpdateCommand is not supported against a SelectCommand that does not return any key column information.
After looking up this error message, I am no further to solving my problem. Can anyone please spot the issue please. Ive provided my code below;
private void updateCaseDB(int rowID, int newCategory)
{
con = new System.Data.SqlClient.SqlConnection();
dsCaseUpdate = new DataSet();
con.ConnectionString = "Data Source=.\\SQLEXPRESS;AttachDbFilename=" + CaseDBLocation + ";Integrated Security=True;Connect Timeout=30;User Instance=True";
con.Open();
string caseUpdateQuery = "SELECT * From CaseDBTemp";
daCaseUpdate = new System.Data.SqlClient.SqlDataAdapter(caseUpdateQuery, con);
daCaseUpdate.Fill(dsCaseUpdate, "CaseDBUpdate");
con.Close();
System.Data.SqlClient.SqlCommandBuilder cbupdate;
cbupdate = new System.Data.SqlClient.SqlCommandBuilder(daCaseUpdate);
System.Data.DataRow dRow = dsCaseUpdate.Tables["CaseDBUpdate"].Rows[rowID];
dRow[7] = newCategory;
MessageBox.Show("row: "+ rowID + " - New Category Value: " + newCategory);
daCaseUpdate.Update(dsCaseUpdate, "CaseDBUpdate");//*this is the problem line*//
MessageBox.Show("row updated");
}