473,406 Members | 2,371 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

updating a datagrid that is bound to a dataset

hello,
I have put thisup b4, but I think that people have misunderstood the problem, so I will make it clearer.

I have a problem updating a dataset that is bound to a datagrid.
The code that I use to set up the grid dgsimple to the dataset Mydataset and the table "Orders" is as below (see bottom of page)

My problem is that I can change data in the datagrid on the first row of the grid and the changes will be immediately written away, However If I change data on the 2nd or subsequent rows the data is not written away until you click on the next row of the grid, and you can't expect users to always click on the next row.

What am I doing wrong, Does the bindingcontext have to specify the exact row of the dataset and just defaults to row 0 if none is specifeld. Please help

Geraldine


Private Sub SetupGrid()

'Fill the DataSet

Dim Mycon As SqlConnection = New SqlConnection(strconn)
Dim strquery As String
strquery = "Exec spOrders " & 402
MySqlDataadapter = New SqlDataAdapter(strquery, Mycon)
MyDataset = New DataSet
MySqlDataadapter.FillSchema(MyDataset, SchemaType.Source, "Orders")
MySqlDataadapter.Fill(MyDataset, "Orders")

Mycon = Nothing

End Sub

Private Sub FormatOrdersGrid()
dgsimple.DataSource = MyDataset
dgsimple.DataMember = "Orders"
dgsimple.SetDataBinding(MyDataset, "Orders")

End Sub
Private Sub dgsimple_CurrentCellChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles dgsimple.CurrentCellChanged

DirectCast(BindingContext(MyDataset.Tables!Orders) , CurrencyManager).EndCurrentEdit()
Dim objCommandBuilder As New SqlCommandBuilder(Mysqldataadapter)
MySqlDataadapter.Update(MyDataset, "Orders")
End Sub
Nov 20 '05 #1
1 1312
Cor
Hi Geraldine,
My problem is that I can change data in the datagrid on the first row of

the grid and the changes will be immediately written away, However If I
change data on the 2nd or subsequent rows the data is not written away until
you click on the next row of the grid, and you can't expect users to always
click on the next row.

I do not understand that your first row is updated while your second not.

The event fires as soon as you click in a new cell or on a new row.
(Not before it or on the top, only real a new cell)
Therefore you do a lot of updates in your program, your dataset is updated
completly everytime when a user clicks another cell or another row.

And you do not do an update when you leave the grid or close the program.

I would choose another event for an update (but I cannot see how frequently
you do want it) and surely check that the update routine also is performed
when you are closing.

To call the event with the clossing you just can do
dgsimple_CurrentCellChanged(nothing, nothing)

I would add miminal this piece of code extra in the program. (To prevent to
much updates)

if myDataset.haschanges then
MySqlDataadapter.Update(MyDataset, "Orders")
end if

I hope this helps something?

Cor
Nov 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: sandman | last post by:
I've got a simple windows form with some bound textboxes and Save button. Each texbox is bound to column in a table in an Access database. The form fills fine - all the fields show the correct...
1
by: Jim | last post by:
I have a dataset-bound datagrid and, when the user adds a row to the datagrid and fills it with the data, I'd like to be able to update the dataset (with the newly-added row) and then the database...
3
by: Diego TERCERO | last post by:
Hi... I'm working on a tool for editing text resources for a family of software product my company produces. These text resources are found in a SQL Server database, in a table called...
9
by: Pam Ammond | last post by:
After clicking btnDeleteSize_Click in frmSize, I move to frmSizeDelete, allow deleting a Size using a datagrid, and then return to frmSize and want to update the datagrid in frmSize to reflect the...
2
by: LC | last post by:
I am on the learn C#. Net in 695 day program. I am just trying to learn stuff. I have MSAccess database with 1 table called 'ParmDate' with 1 column called 'ParmDate' which represents a date for...
2
by: Geir Sanne | last post by:
hi!! how am i supposed to update the db witht he changes the user make in webpage am trying to make a simple page that have a grid bound to a table the user can delete,add or update the grid...
5
by: junglist | last post by:
Hi guys, I've been trying to implement an editable datagrid and i have been succesful up to the point where i can update my datagrid row by row. However what used to happen was that once i updated...
3
by: Datatable Dataset Datagrid help | last post by:
Hi I am somewhat confused, I am new at VB.net I use XML data, I have a datagrid, I created a datatable so that I can create a custom format like true is this graphic false is this graphic and...
2
by: Greg | last post by:
I'm using the Framework 1.1, so I don't have access to the new DataGridView object. What I'm wondering is, is there a really simple way to bind a plain datagrid to a database in such a way that...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.