|
-
Jan 21st, 2010, 05:22 AM
#1
Thread Starter
Hyperactive Member
Datagridview - saving data
Good morning to everyone.
In VB.net 2008 I would like to have a datagridview in a form.
This datagridview, show the data of one MDB table.
I pretend the user can change data, and save them.
BUT, I DON'T want use the default save button created by the VB in the header of the form.
Cause I have extra code to do in saving moment, I need to create my "save" button.
What code should I enter in the click event of the button???
I've tried many solutions, but none of them works..
Thank You
-
Jan 21st, 2010, 05:24 AM
#2
Fanatic Member
Re: Datagridview - saving data
Code:
Using con As New OleDbConnection("Provider=Microsoft.Jet.Oledb.4.0;Data Source=db1.mdb")
con.Open()
cmd = New OleDbCommand("Select * from Table1", con)
Dim da As New OleDbDataAdapter(cmd)
Dim dt As New DataTable
da.Fill(dt)
DataGridView1.DataSource = dt
End Using
-
Jan 21st, 2010, 06:08 AM
#3
Thread Starter
Hyperactive Member
Re: Datagridview - saving data
Tommy,
It wasn't that I needd.
In another forum, answer me and work with:
Me.Validate()
Me.MovBindingSource.EndEdit()
Me.TableAdapterManager.UpdateAll(Me.ApDataSet)
But now, I have another big problem.
How can I alter a global var, is any valu eof datagridview is changed?
No one of the events works
-
Jan 21st, 2010, 08:49 AM
#4
Hyperactive Member
Re: Datagridview - saving data
It all depends on how the databinding to the datagridview has been setup. If you have bound the datatable directly to the dgv and setup the Insert, Delete & Update sql statements in the dataset designer (note : datatable must have an Index) then the code would be :
Code:
Me.Validate
Me.datatableBindingSource.EndEdit()
Me.datatableTableAdapter.Update(datatable)
So no matter what you do in the dgv the data will be updated. This is the easiest way to handle data in the dgv.
Computerman
It was much easier in VB6, but I am now liking Vb.Net alot more. 
-
Jan 21st, 2010, 09:08 AM
#5
Thread Starter
Hyperactive Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|