|
-
Jan 29th, 2008, 12:00 PM
#1
Thread Starter
Member
[RESOLVED] Sql Queries
I am developing a Win forms Application in VB.NET 2005.
I have two queries, how do I add a new row to my data grid without getting the Rows cannot be programmatically added to the DataGridView's rows collection when the control is data-bound error
Also can someone tell me why I am getting a Update requires a valid UpdateCommand when passed DataRow collection with modified rows
error please.
I have pasted my code below, thanks.
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
MsgBox("64 " + Me.DataGridView2.Rows.Count.ToString)
MsgBox("65 " + Count.ToString)
Me.DataGridView2.Rows(Count - 1).Cells.Item(0).Value =
Me.RaceDate.Text
Me.DataGridView2.Rows(Count - 1).Cells.Item(1).Value =
Me.RaceTime.Text
MsgBox("68 " + Me.VsrDataTableAdapter.Connection.State.ToString)
Me.VsrDataTableAdapter.Update(Me.EquinexMasterSqlDataSet.VsrData)
Me.DataGridView2.Update()
MsgBox("73 " + Count.ToString)
Count = Count + 1
End Sub
-
Jan 29th, 2008, 12:05 PM
#2
Re: Sql Queries
Don't add rows to the datagrid. Add the rows to the underlaying source to which the datagrid is bound, and then refresh the datagrid.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|