soonhuat81

soonhuat81

  • NA
  • 31
  • 0

Update Error - Please

Jun 24 2004 5:46 AM
I have a datagrid(with the column ProductID and etc) onto my form(form1) ... I also have all the same field in textedit/lookupedit format corresponding to each of the column in datagrid...and here is how i do the binding.. DataGrid - Bind its datasource to DataTableOrderDetail lookupeditProductID - This lookupedit will get the data from another table call "PRODUCT" and the following is how i bind it: lookupeditProductID.DataBindings.Add(new System.Windows.Forms.Binding("EditValue", DataTableOrderDetail;"ProductID")); lookupeditProductID.Properties.DataSource = DataTableProduct; lookupeditProductID.Properties.DisplayMember = "Description"; lookupeditProductID.Properties.ValueMember = "ProductID"; The system is work fine each time i locate the new ProductID from DataTableProdct .. but after i have edit and change the data for lookupeditProductID field and Save it, the following error message prompt out .. "An unhandled exception of type 'System.InvalidOperationException' occurred in system.data.dll Additional information: Dynamic SQL generation for the UpdateCommand is not supported against a SelectCommand that does not return any key column information." For your info, here i the code i write for the Save function: SqlConnection aconnect = new SqlConnection(myConnectionString); aconnect.Open(); SqlCommand aCmd = new SqlCommand("SELECT * FROM OrderDetail", aconnect); SqlDataAdapter sqlDataAdapter1 = new SqlDataAdapter(aCmd); SqlCommandBuilder aCmdBuilder = new SqlCommandBuilder(sqlDataAdapter1); sqlDataAdapter1.Update(DataTableOrderDetail); aconnect.Close(); What's wrong with my code ?? I hope some one can help as this is in urgent thanks.

Answers (1)