hello Experts,
i have a datagridview and a textbox. i want to update the cells programetically but there is error "Dynamic SQL generation for the UpdateCommand is not supported against a SelectCommand that does not return any key column information." here is my code:
fill datagrid button code:
ada = New SqlDataAdapter
ds = New DataSet
con.ConnectionString = strCon
con.Open()
ada.SelectCommand = New SqlCommand("SELECT transaction_id,payment_no,due_date_of_payment,monthly_payment FROM customer_transaction where transaction_id='" & TextBox1.Text & "'", con)
cb = New SqlCommandBuilder(ada)
ada.Fill(ds)
DataGridView1.DataSource = ds.Tables(0)
con.Close()
update button code:
For i = 0 To ds.Tables(0).Rows.Count - 1
ds.Tables(0).Rows(i).BeginEdit()
ds.Tables(0).Rows(i).Item("monthly_payment") = val(textbox2.text)--- update by this value
ds.Tables(0).Rows(i).EndEdit()
Next
If ds.HasChanges Then
ada.Update(ds)
where i m doing wrong....... in my table (transaction_id + payment_no) is primary key....please help me...!!!!!!!!!
i have a datagridview and a textbox. i want to update the cells programetically but there is error "Dynamic SQL generation for the UpdateCommand is not supported against a SelectCommand that does not return any key column information." here is my code:
fill datagrid button code:
ada = New SqlDataAdapter
ds = New DataSet
con.ConnectionString = strCon
con.Open()
ada.SelectCommand = New SqlCommand("SELECT transaction_id,payment_no,due_date_of_payment,monthly_payment FROM customer_transaction where transaction_id='" & TextBox1.Text & "'", con)
cb = New SqlCommandBuilder(ada)
ada.Fill(ds)
DataGridView1.DataSource = ds.Tables(0)
con.Close()
update button code:
For i = 0 To ds.Tables(0).Rows.Count - 1
ds.Tables(0).Rows(i).BeginEdit()
ds.Tables(0).Rows(i).Item("monthly_payment") = val(textbox2.text)--- update by this value
ds.Tables(0).Rows(i).EndEdit()
Next
If ds.HasChanges Then
ada.Update(ds)
where i m doing wrong....... in my table (transaction_id + payment_no) is primary key....please help me...!!!!!!!!!