Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm Data Binding / July 2004

Tip: Looking for answers? Try searching our database.

Saving bound vb.net datagrid changes (newbie)

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Michael - 23 Jul 2004 04:26 GMT
Hello!

I'm having a problem getting this functionality working and was hoping
someone could point me in the right direction.

I'm using VB.NET 2002 and I'm trying to dynamically bind an access db
table to a datagrid and then save changes made to the data in the grid.

My form constructor looks like this:

         ' sConnection, oAD, and oDS are previously defined

       Dim oCon As New System.Data.OleDb.OleDbConnection(sConnection)
       oCon.Open()

       Dim sCommand As String
       sCommand = "SELECT * FROM tblItem"
       oAD = New System.Data.OleDb.OleDbDataAdapter(sCommand, oCon)

       Dim oBuild As New System.Data.OleDb.OleDbCommandBuilder(oAD)
       oAD.UpdateCommand = oBuild.GetUpdateCommand()

       oDS.Clear()
       oAD.Fill(oDS, "tblItem")

       Me.DataGrid1.DataSource = Me.oDS.Tables("tblItem")

And then under my save button, I've got the following:

         Try
           oAD.Update(oDS)
       Catch ex As Exception
           MsgBox(ex.ToString)
       End Try

The message I get is "Update unable to find TableMapping['Table'] or
DataTable 'Table'."  I thought that assigning the datasource using
Me.oDS.Tables("tblItem") uses a datatable object.

Does anyone have any suggestions?

Thanks in advance!

Michael
Ken Tucker [MVP] - 23 Jul 2004 14:19 GMT
Hi,

       Try this

oAD.Update(oDS, "tblItem")

Ken
-----------------
Hello!

I'm having a problem getting this functionality working and was hoping
someone could point me in the right direction.

I'm using VB.NET 2002 and I'm trying to dynamically bind an access db
table to a datagrid and then save changes made to the data in the grid.

My form constructor looks like this:

      ' sConnection, oAD, and oDS are previously defined

       Dim oCon As New System.Data.OleDb.OleDbConnection(sConnection)
       oCon.Open()

       Dim sCommand As String
       sCommand = "SELECT * FROM tblItem"
       oAD = New System.Data.OleDb.OleDbDataAdapter(sCommand, oCon)

       Dim oBuild As New System.Data.OleDb.OleDbCommandBuilder(oAD)
       oAD.UpdateCommand = oBuild.GetUpdateCommand()

       oDS.Clear()
       oAD.Fill(oDS, "tblItem")

       Me.DataGrid1.DataSource = Me.oDS.Tables("tblItem")

And then under my save button, I've got the following:

      Try
           oAD.Update(oDS)
       Catch ex As Exception
           MsgBox(ex.ToString)
       End Try

The message I get is "Update unable to find TableMapping['Table'] or
DataTable 'Table'."  I thought that assigning the datasource using
Me.oDS.Tables("tblItem") uses a datatable object.

Does anyone have any suggestions?

Thanks in advance!

Michael
Michael - 23 Jul 2004 16:58 GMT
Thanks, Ken -- it works great now.

It's always the silly things.  I need to get used to the overloaded
functions in vb.net.

Michael

"Ken Tucker [MVP]" <vb2ae@bellsouth.net> wrote in news:OptrAfLcEHA.716
@TK2MSFTNGP11.phx.gbl:

> Hi,
>
[quoted text clipped - 4 lines]
> Ken
> -----------------

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.