Subject: VSTO Update database
Posted By: T Hallmark Post Date: 7/18/2006 9:17:04 PM
I am having a problem trying to undate a Dataset in Excel to an Access data base. I am using VSTO 2005 with office 2003. This is the code I am trying to use but it errors and tells me that Validate and Update are not a member of Workbook.sheet1  Sheet1 is where I have the button. Obviously I am missing something but being I am a VBA guy trying to learn .net I am having some problems.

Thanks for any help.
Tom Hallmark

Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdate.Click

        Try
            Me.Validate()
            Me.TRgraphBindingSource.EndEdit()
            Me.TRgraphTableAdapter.Update(Me.TRgraphDBDataSet.TRgraph)
            MsgBox("Update successful")

        Catch ex As Exception
            MsgBox("Update failed")
        End Try
    End Sub
Reply By: alvinjohnbruney Reply Date: 7/21/2006 4:49:58 PM
A few things: Try to avoid the use of commandbuilder objects. I've made the assumption that TRgraphTableAdapter is a commandbuilder. The reason for this is that these objects build inefficient query code that introduces unnecessary load on the database.

The code Me.Validate() calls the validate object on the object currently on the execution stack. This is most likely the worksheet object and it does not contain that method. You can try TRgraphBindingSource.Validate if TRgraphBindingSource is an update object.

Finally, You have called EndEdit(), I don't see a beginedit(). The two need to be paired for consistent results since they are asynchronous method calls.

I'd suggest you back track and start over with a simple query. Once you get the query working you can calls to the data objects as needed.

Reply By: T Hallmark Reply Date: 7/21/2006 6:31:52 PM
Thanks for your reply. I think the adds microsoft made saying how easy it connect excel with a database were overestimated. Does anyone know of a good beginners book for vsto that includes the database updating?

Regards,
Tom

T Hallmark
Reply By: hkec Reply Date: 7/25/2006 3:03:09 PM
I am looking for the same book or code. It would be great if someone can share this information.
Reply By: fix105 Reply Date: 8/25/2006 7:48:33 AM
Same for me, i have some problems with insert when i use more than one table in a listObject.
I would like to insert or update by the listObject (array)

Reply By: gigaboy Reply Date: 11/29/2006 1:00:17 AM
I cant help but to say i think it would be easier to create a database that inserts into excel instead of the other way around, yes excel can insert into access but i think you need to setup an odbc connection and get a gob of connection code working (unless im mistaken) ...I know there are ways to bind excel worksheets to tables in access because ive done it before it would be much easier to update the tables and use the shell command to open the worksheets

Go to topic 52949

Return to index page 108
Return to index page 107
Return to index page 106
Return to index page 105
Return to index page 104
Return to index page 103
Return to index page 102
Return to index page 101
Return to index page 100
Return to index page 99