Home Forums WinForms controls Xceed Grid for WinForms simple databinding question

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #13268 |

    Hi Guys,

    This is my first attempt to use the Xceed Grid (and in fact, I’m still very new to .NET). I’m quite impressed with the features, esp. over the basic datagrid that is shipped with .NET. Anyway, enough of that, here is my problem.

    I have built a very simple form that connects to an access database (just one autonumber column and text column). I have also choosen to manually define the dataset, dataadaptor, etc so I get become more familiar with that way things are done in .NET.

    It all works fine (i.e. I can update, delete and view data) however after successfully updating data – I recieve the following error:

    An unhandled exception of type ‘System.InvalidOperationException’ occurred in xceed.grid.dll
    Additional information: An attempt was made to select a row that does not belong to a grid.

    Any ideas guys.. I’m sure it’s something really basic, but I can’t seem to work it out. Here is the code: (Note, I’ve removed the validation code)

    Dim mConn As OleDb.OleDbConnection
    Dim lcGlobalValue As cGlobalConfig

    ‘Project list global variable list
    Dim daProjectList As OleDb.OleDbDataAdapter
    Dim dsProjectList As DataSet
    Dim cmProjectList As CurrencyManager

    Private Sub frmProjects_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
    PrepareProjectListGrid()
    End Sub

    #Region ” Database “

    Private Sub PrepareProjectListGrid()
    Dim sSQLString

    ‘Firstly, define the dataadaptor, dataset and Command statements.
    ‘ —————————– Data Adaptor / Data Set —————————-
    mConn = New OleDb.OleDbConnection(lcGlobalValue.pProvider & lcGlobalValue.pDataSource)

    sSQLString = ” SELECT prs_projectID, ” & _
    ” prs_name, ” & _
    ” prs_createdDate, ” & _
    ” prs_lastUpdateDate ” & _
    ” FROM tblProjectSummary_PRS “

    daProjectList = New OleDb.OleDbDataAdapter(sSQLString, mConn)
    dsProjectList = New DataSet

    daProjectList.Fill(dsProjectList, “tblProjectSummary_PRS”)

    ‘ —————————– Update / Insert / Delete Commands ——————–
    daProjectList.UpdateCommand = New System.Data.OleDb.OleDbCommand(“UPDATE tblProjectSummary_PRS SET prs_name = ? WHERE prs_projectID = ?”, mConn)
    daProjectList.UpdateCommand.CommandType = CommandType.Text
    daProjectList.UpdateCommand.Parameters.Add(“@prs_name”, System.Data.OleDb.OleDbType.Char, 50, “prs_name”)
    daProjectList.UpdateCommand.Parameters.Add(“@prs_projectID”, System.Data.OleDb.OleDbType.Integer, 50, “prs_projectID”)

    daProjectList.InsertCommand = New System.Data.OleDb.OleDbCommand(“INSERT INTO tblProjectSummary_PRS (prs_name) Values (?)”, mConn)
    daProjectList.InsertCommand.CommandType = CommandType.Text
    daProjectList.InsertCommand.Parameters.Add(“@prs_name”, System.Data.OleDb.OleDbType.Char, 50, “prs_name”)

    daProjectList.DeleteCommand = New System.Data.OleDb.OleDbCommand(“DELETE FROM tblProjectSummary_PRS WHERE prs_projectID = ?”, mConn)
    daProjectList.DeleteCommand.CommandType = CommandType.Text
    daProjectList.DeleteCommand.Parameters.Add(“@prs_projectID”, System.Data.OleDb.OleDbType.Integer, 50, “prs_projectID”)
    ‘ ————————————————————————————–

    dgProjectList.BeginInit()
    dgProjectList.DataSource = dsProjectList
    dgProjectList.DataMember = “tblProjectSummary_PRS”

    ‘ ——————————- Assign Event Handlers ——————————-
    AddHandler dgProjectList.DataRowTemplate.EditEnded, AddressOf Me.dgProjectList_DataRow_EditEnded
    ‘AddHandler dgProjectList.AddingDataRow, AddressOf Me.dgProjectList_DataRow_AddingDataRow

    AddHandler dgProjectList.DataRowTemplate.EndingEdit, AddressOf Me.dgProjectList_DataRow_EndingEdit

    AddHandler dgProjectList.DataRowTemplate.EditEnded, AddressOf Me.dgProjectList_DataRow_EditEnded

    AddHandler dgProjectList.DataRowTemplate.ValidationError, AddressOf Me.dgProjectList_DataRow_ValidationError

    dgProjectList.EndInit()
    End Sub

    Private Sub dgProjectList_DataRow_EditEnded(ByVal sender As Object, ByVal e As System.EventArgs)

    Try
    daProjectList.Update(dsProjectList, “tblProjectSummary_PRS”)
    dsProjectList.AcceptChanges()
    Catch except As Exception
    MessageBox.Show(except.ToString())
    End Try

    End Sub

    Imported from legacy forums. Posted by aobed (had 6885 views)

    User (Old forums)
    Member
    Post count: 23064

    I’ve had the same issue and was told its a bug in the product. Here is tech supports response.

    “Yes, this is indeed a bug and I will add it to our next bug fixing session due in a few weeks. Meanwhile, you can do the update during a timer event (or in the Application.Idle). The activation of the Timer (Or subscription to Application.Idle ) will have to be done during the same event that right now you are saving the current data change.”

    Imported from legacy forums. Posted by ralexand (had 315 views)

    User (Old forums)
    Member
    Post count: 23064

    Thanks ralex.

    Forgive my ignorance, but it’s amazing that such a simple feature (updating data attached to a dataset) has a bug? Aside from the timer method, is there another event that I could subscribe to call the update?

    I appreciate the post back mate – did you solve the problem using the tech support solution?

    Imported from legacy forums. Posted by aobed (had 438 views)

    User (Old forums)
    Member
    Post count: 23064

    I’m trying to solve the problem myself, I don’t know how to subscribe to both events, Datarowchanged and Application idle. I too was shocked that such big bug made it through. If I figure out something, I will post it here.

    Imported from legacy forums. Posted by ralexand (had 460 views)

    User (Old forums)
    Member
    Post count: 23064

    Hi mate,

    Just wondering if you’ve had any luck with the above? I tried tech support as well (just in case another solution is avail or an example of how to get around this problem). A couple of days and no response, but I will be patient and wait as this grid is very cool.

    Are you working on a commerical project or using it as a learning tool? Have you tried any other grids or other solutions since you posted last?

    Imported from legacy forums. Posted by aobed (had 280 views)

    User (Old forums)
    Member
    Post count: 23064

    Hi ralexand,

    Just to let you know, this morning I recieved quite a detailed reply to the issue we’re having. Perhaps the issue is more to do with our code than the component itself. I’ll give this a go tonight, and post my findings.

    All the best.

    Imported from legacy forums. Posted by aobed (had 278 views)

    User (Old forums)
    Member
    Post count: 23064

    Thanks, aobed. I hope you’re right. I sent them an example by commenting out their update method in their grid sample and I was able to duplicate the error.

    Imported from legacy forums. Posted by ralexand (had 362 views)

    User (Old forums)
    Member
    Post count: 23064

    aoebed, can you forward me the response you got concerning this issue?

    Imported from legacy forums. Posted by ralexand (had 372 views)

    User (Old forums)
    Member
    Post count: 23064

    Any advancement on this?

    To replicate this error, i edit a column, and then without actually leaving the edit on that column, i click on another cell to edit it.

    Any ideas?

    Thanks!

    Imported from legacy forums. Posted by apollo (had 542 views)

    User (Old forums)
    Member
    Post count: 23064

    I ran across this same error, is there a fix or workaround?

    Imported from legacy forums. Posted by dbrownie (had 7929 views)

Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.