Results 1 to 2 of 2

Thread: [RESOLVED] Sql Queries

  1. #1

    Thread Starter
    Member
    Join Date
    Feb 2006
    Posts
    59

    Resolved [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

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    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
  •  



Click Here to Expand Forum to Full Width