[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Updating Database using VB.NET Datagrid and Storedprocedure

Posted on 2004-10-11
7
Medium Priority
?
153 Views
Last Modified: 2010-04-23
Hello I am Populating a datagrid by binding a DataView to the the Datagrid. The Dataview is built from Storedprocedure Query.
Can anyone tell me how can I propogate the changes in the datagrid back to the database. I am assuming the user may of chaged values in multiple rows of the datagrid.

Below is a snippet of code that binds the SP results to the datagrid.

Many Thanks


Dim oShowcode As Object
        Dim oShowyear As Object
        Dim oStartdate As Object
        Dim oEnddate As Object
        Dim oerror As Object
        Dim oBatch As Object

        Dim mydatatable As New DataTable
        mydatatable = myConnection.ArSPExecReturnDataTable("PrsgDocumentrequestbatchAdmin", oShowcode, oShowyear)
        'mydataset.Tables.Add(mydatatable)
        Dim mydataset As New DataSet
        Dim mydataview As DataView = New DataView(mydatatable)

        mydataset = mydatatable.DataSet
        mydataset.Tables(0).TableName = "results"

        MyDataGrid.DataSource = mydataview
0
Comment
Question by:anwarmir
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
7 Comments
 
LVL 28

Expert Comment

by:iboutchkine
ID: 12277990
If you are using dataadapter then you can

Dim cb As New OleDbCommandBuilder(da)
 da.Update(ds, "MyTable")
0
 

Author Comment

by:anwarmir
ID: 12278023
But that only updates the dataadapter. How can I update each updatedrow in the grid be updated to the database
0
 
LVL 28

Expert Comment

by:iboutchkine
ID: 12278169
Your dg is bound to the datatable. Every update in dg will be reflected in the dt. Dataadapter will update the underlying table
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 10

Expert Comment

by:Hans Langer
ID: 12278497
Hi,
You can see DataAdapter.UpdateCommand  property in this article, maybe that help you,

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconupdatingdatabasewithdataadapterdataset.asp

Good Luck
0
 

Author Comment

by:anwarmir
ID: 12295753
Thanks...But I have just one more question are you saying that although I populated  the datagrid with a storedprocedure. Any changes to the Dataadapter.Datagrid will automatically take place. I would not have to write a Storedprocedure which Updates the database. The thing that confuses me is how does the datagrid know which table to update ?

Thanks
0
 
LVL 10

Expert Comment

by:Hans Langer
ID: 12297185
You must define Storedprocedure that Update the database.

The datagrid is binded to the dataset and the dataset know how to update the data source.
0
 
LVL 10

Accepted Solution

by:
Hans Langer earned 750 total points
ID: 12297255
The dataset look for property RowState of its DataTable.Rows and he update only de row they are changed state.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question