update data on table with datagrid, where I am usedto usign 2003 now trying to do it in 2005

Posted on 2007-08-12
Last Modified: 2013-11-05
I am now using 2005.  How do I update.delete,edit with datagridview whereas I used to use a
dbcon then data adapter, then a dataset, thenmonitored the changes.  

How do I do it in 2005.

Question by:mphillip85
    LVL 18

    Expert Comment


    There is really not that big change's regarding working against datasource's in 2005
    But if you are or want to work with designer/wizzards i think there are alot of improvements in that regard.

    Here is a walktrough
    Walkthrough: Saving Data to a Database

    Though you can still use data adapter instead of the tableadapter provided in 2005

    But in 2005 intellisence provides the capabillity to visual examine objects , data containers ,dataset's, ect... in debug mode which i think is one of the really good new features in 2005.


    Author Comment

    can you throw me a few lines as what are the new ways.

    I seem to have 2 icons
    1 data connection
    1 dataset that ties to the datagridview

    so what code do i need to just add a row in the datagrid, then update the table

    before I would do a dataadapter.update(dataset)

    or dataadapter.upadatecommand.commandtext = update table myfield = my value where myid = id

    Just a quick new few lines will get me going in the right direction.  tghanks


    Author Comment

    here is my code :

    Function DataGridUpdate()
            On Error Resume Next
            If Me.Redwood_III.State = ConnectionState.Closed Then
            End If



            Return Nothing
        End Function

     Private Sub ftp_http_DataGridView_CellValueChanged(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles ftp_http_DataGridView.CellValueChanged
        End Sub

    it works it stops its partial works.


    shall I close and re-open connection each time I call the function?
    LVL 18

    Assisted Solution


    First! you dont need to open or validate if the connection is open !
    The Table adapter contains all the relevant information in that regard , of course if you used the adapter fill method
    to fill you table into the dataset.

    These lines of code will update 1 single table in the dataset

     Private Sub ftp_http_DataGridView_CellValueChanged(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles ftp_http_DataGridView.CellValueChanged

        MsgBox("Update successful")

    Catch ex As Exception
        MsgBox("Update failed")
    End Try
        End Sub

    If you are using the datagridview to modify data within it ,it is though important that you set the grid to endedit()
    DataGrid.EndEdit() , Before calling the adapters update method.
    That way the table in the dataset now reflects all the changes you've made in the grid and not loosing any data.

    Hope this helps a bit

    LVL 16

    Accepted Solution

    I wrote this walkthrough with images.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    The object model of .Net can be overwhelming at times – so overwhelming that quite trivial tasks often take hours of research. In this case, the task at hand was to populate the datagrid from SQL Server database in Visual Studio 2008 Windows applica…
    It’s quite interesting for me as I worked with Excel using for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    758 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

    Need Help in Real-Time?

    Connect with top rated Experts

    9 Experts available now in Live!

    Get 1:1 Help Now