index > Visual Studio Tools for Office > How to update SQL 2005 database on a VBNET Excel 2003 Project

How to update SQL 2005 database on a VBNET Excel 2003 Project

Hi,

I'm wondering if somebody can help me. I have a VSTO 2005 VB.NET excel 2003 project that I'm trying to automate. I have Listobject in the excel project that I'm able to populate data from an SQL 2005 database with no problem. My question is the following. How do I update the database with the changes I make to the listobject I have on my excel project? I have looked at the VSTO samples but I can't get this to work. When I close and run my solution a second time, the changes that I made to the listobject previously do not get saved back to the database. Why is that?? I'm kind of new to VSTO so I'm not sure how to go about this.

Any help anyone can provide will be greatly appreciated.

VBNET_Fanatico

You need to commit the changes that are in the memory instance of the dataTable back to the database. Use the Update method on the tableAdapter that is created for you to do this. e.g., if you had the northwind data set's customers table bound to the listObject, you would update the database with the following code:

this.customersTableAdapter.Update ( this.northwindDataSet.Customers );

Thanks.




This posting is provided "AS IS" with no warranties, and confers no rights.
Mohit Gupta - MSFT

Yes you are correct. I'm using this but the database doesn't get update. I have a Listobject on Sheet1 that gets populated with the dataset correctly with the corresponding table. Here's the code snippets from the project.

Private Sub Sheet1_Startup(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Startup

If Me.NeedsFill("NorthwndDataSet") Then

Me.EmployeesTableAdapter.Fill(Me.NorthwndDataSet.Employees)

End If

Me.Button1.Text = "Save"

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Try

Me.EmployeesTableAdapter.Update(Me.NorthwndDataSet.Employees)

Catch ex As System.Data.DataException

MessageBox.Show(ex.Message)

End Try

End Sub

- Here's what I do. 1. Run the project. 2. Make changes to some of the fields of the listobject. 3. Click Button1 to save changes. 4. Close the project. 5. Open the project again. 6. Changes I made were not saved.

Any ideas?? I'm using VS2005, Office 2003.

VBNET_Fanatico

Please make sure that the update command on the table adapter has actually been configured and initialized. In the default data sources wizard, only the select command is created on the table adapter. Look at the generated code in your source files on the table adapter to see if the update command has been set in it.




This posting is provided "AS IS" with no warranties, and confers no rights.
Mohit Gupta - MSFT

Is this a bug in the wizard? I looked at the generated code and it looks like the update command has been configured and initialized correctly. Not sure what part of the generated code is causing this problem? Can you post a code snippet of what additional generated code should be added and where it should be pasted to the update command of the adapter? There's too much generated code and therefore I'm not sure what's missing.

BTW - This is the example from the Visual Studio 2005 Excel Walkthroughs "Binding Cells to Multiple Columns in a Table".

Thanks for you help..

VBNET_Fanatico
reply 5

You can use google to search for other answers

 

More Articles

• How to determine the type of the Outlook Attachment?
• Error opening Dec CTP VSTO Project
• Find.Execute throws "Command is not available" error
• How can we add a userdefined chart type to xlgallery, progrmatica...
• Selection.PasteExcelTable
• VSTO 2003 basics
• _ComObject specified cast exception calling add-in interface meth...
• Visual Basic 2005 and MSWord Rule Bar
• VstoSmartTags from a COM Add-In
• Please help: Document Protection Programmatically
Bookmark and Share
Welcome to Bokebb   New Update  
 

New Articles

• Custom Task Panes in Outlook 2003
• Does the client needs .net framework 2?
• Launch conditions
• Avoiding security alert in Outlook while
• Saving workbook from template without co
• VSTO Properties Settings are the same as
• Can a VSTO 2005 Excel Application be sta
• How to Read a Date from other sheet in C
• renaming an Excel sheet
• How to integrate multiple word templates
• How to: Interact with Windows Forms (C#
• VSTO Outlook Calendar
• Range.get_Information() is causing Appli
• Opening worksheet in VS 2005 RTM crashes
• Outlook saves my mail to drafts instead

Hot Articles

• Do multiple instances of the same VSTO s
• PowerPoint "custom animation"
• Question about "Toolbar Button Face
• Help with Word Interop PLEASE!!! - more
• How Digital Signature work.
• Excel Sheet Switching/Hiding
• c# automation - copy excel table to a po
• Order of selection events with Bookmark
• How to control the cell's datatype of Ex
• VSTO project does not appear in "VS
• font formating
• How to copy the sheet on excel developme
• VSTO Deployment Installation
• Now Available: Visual Studio Tools for O
• How to create shortcut of excelsheet

Recommend Articles

• Add a control to PowerPoint slides
• How can I call my outlook form instead o
• List to install to develop office applic
• Problem while publishing Metadata for IB
• Does VSTO solution work with Word 2002 a
• where can i find vsto apis for word proj
• Setting data source programmatically for
• Create CommandBarButtons on an email usi
• Retrieve image content in Excel range us
• RequestService problem with Creating Out
• Not sure if this is the right place to p
• nesting multiple sumif statements
• regarding actionspane
• Excel errors
• VSTO2005 Excel- Insert Comment into cell