[Last Call] Learn how to a build a cloud-first strategyRegister Now


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

Posted on 2007-08-12
Medium Priority
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
  • 2
  • 2
LVL 18

Expert Comment

ID: 19680040

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

ID: 19680272
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

ID: 19680544
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

vbturbo earned 1000 total points
ID: 19681740

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

RobertRFreeman earned 1000 total points
ID: 19686110
I wrote this walkthrough with images.

Featured Post

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

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

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses
Course of the Month18 days, 6 hours left to enroll

830 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