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

x
?
Solved

Update db from datagrid

Posted on 2004-09-08
5
Medium Priority
?
163 Views
Last Modified: 2010-05-18
My datagrid's datasource is a db table.

If the user edits a cell, how do I update the db with the change?  

I need to know what value has changed and make an update to SQL Server.

A code snippet, svp.

capt
0
Comment
Question by:Glen Gibb
[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
5 Comments
 
LVL 18

Accepted Solution

by:
DotNetLover_Baan earned 800 total points
ID: 12012564
0
 
LVL 22

Assisted Solution

by:Mohammed Nasman
Mohammed Nasman earned 200 total points
ID: 12013698
Hello

  Use SqlDataAdapter to fill Dataset, and then bind the DataGrid to the Dataset
when you would like the changes that happen to the Datagrid to be updated to sql server, use SqlDataAdapter.Update for that

it's easy and doesn't require from you much code ;-)
0
 
LVL 27

Assisted Solution

by:planocz
planocz earned 800 total points
ID: 12015490
Sample code.............

    Public DS As DataSet
    Public CurRow As DataRow
    Public sTableName As String = "MyTable"
    Public myDataAdapter As OleDb.OleDbDataAdapter
    Dim icnt As Short = 0

        For Each CurRow In DS.Tables(sTableName).Rows
            CurRow.BeginEdit()
            CurRow("OnHand") = datagrid.Item(icnt, 1)         '<---- Column 1
            CurRow("Name") = datagrid.Item(icnt, 2)            '<---- Column 2
            CurRow.EndEdit()
            icnt +=1
        Next
        myDataAdapter.Update(DS.Tables(sTableName))
        MsgBox("Records edited successfully")
0
 
LVL 5

Assisted Solution

by:thenrich
thenrich earned 200 total points
ID: 12015540
I'd use the commandBuilder class since it's a single table.
0
 

Author Comment

by:Glen Gibb
ID: 12031327
Thanks, all.

capt
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
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…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
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