0

I am using Microsoft Visual Basic 2010 Express. I have a WPF-based project. I have a successful connection to a database in Database Explorer, and a working existing Data Source in Data Sources.

I created a datatable from the datasource using this code:

Dim roster_table As New DataTable("AGENT_ROSTER")

I can manipulate this datatable just fine, but I cannot figure out how to save its data to my database (agentroster.sdf) since the connection is on a global level, and isn't declared in this particular window.

How do I update this database from the datatable on this window?

By the way, I tried creating a connection on this window's code, using the exact same connection string as the successful globally-connected database, yet it said that it couldn't connect.

CodeMouse92
  • 6,840
  • 14
  • 73
  • 130

1 Answers1

0

Tough to say given the limited information you provided. You should also note that there are a lot of ways to do this. However the most basic way is to use a table adapter. Once you've set the Update, Insert and Delete commands you call its Update method.

Here's an MSDN article that might help you further

Conrad Frix
  • 51,984
  • 12
  • 96
  • 155
  • You'd be surprised to know that your answer actually helped me solve! I sometimes have a tough time connecting these concepts with my project. The code I used was "Dim table_adaptor As New AGENT_ROSTERTableAdaptors.AGENT_ROSTERTableAdaptor" My only other question is...should that work? – CodeMouse92 Jan 13 '11 at 20:14
  • @JasonMc92. Yep, that looks right. Once you've gained some comfort with ADO.NET, it may be worth while at what other [people are doing](http://stackoverflow.com/questions/363222/is-everyone-here-jumping-on-the-orm-band-wagon) – Conrad Frix Jan 13 '11 at 20:20