Click here to Skip to main content
15,915,164 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: How to process data from serial device Pin
Luc Pattyn5-Aug-07 2:38
sitebuilderLuc Pattyn5-Aug-07 2:38 
GeneralRe: How to process data from serial device Pin
Fu Manchu5-Aug-07 12:15
Fu Manchu5-Aug-07 12:15 
GeneralRe: How to process data from serial device Pin
Luc Pattyn5-Aug-07 13:04
sitebuilderLuc Pattyn5-Aug-07 13:04 
GeneralRe: How to process data from serial device Pin
Fu Manchu5-Aug-07 23:25
Fu Manchu5-Aug-07 23:25 
QuestionDatagrid view to DataBase - Update Pin
NANCO5-Aug-07 2:17
NANCO5-Aug-07 2:17 
AnswerRe: Datagrid view to DataBase - Update Pin
Johan Hakkesteegt6-Aug-07 20:36
Johan Hakkesteegt6-Aug-07 20:36 
QuestionRe: Datagrid view to DataBase - Update Pin
Trupti Mehta7-Aug-07 19:25
Trupti Mehta7-Aug-07 19:25 
AnswerRe: Datagrid view to DataBase - Update Pin
Johan Hakkesteegt7-Aug-07 22:51
Johan Hakkesteegt7-Aug-07 22:51 
Hi Terry,

Trupti Mehta wrote:
Private Sub UpdateDetails()
If (MsgBox("Are you sure to Update the Changes made? ", MsgBoxStyle.YesNo, "Update Details") = MsgBoxResult.Yes) Then
' Me.EmpDataSet.Tables("tblEmployee").AcceptChanges()
Dim i As Integer = Me.TblEmpTableAdapter.Update(Me.EmpDataSet.tblEmployee)
Me.EmpDataSet.AcceptChanges()
MsgBox("Updated Status = " + i.ToString())
End If
End Sub


The first thing that I notice in your code, is that you called .AcceptChanges and then .Update and then once again .AcceptChanges. This is not necessary and in this case would have even caused the problem.

Here is why: when a user makes changes in the datagrid, the rowstate of the rows in the linked DataSet will change accordingly. Change a value and the rowstate becomes something like "changed", delete a row and its rowstate becomes "deleted" (or that is the general idea anyway). When you call .Update the dataset will compare the rows with an altered rowstate, with the corresponding rows in the database, implement the changes where necessary, and finally reset the rowstates and refresh the dataset.

Now when you first call .AcceptChanges all these rowstates are reset. When you now call .Update there are no altered rowstates, and therefore the dataset has nothing to compare, nor implement.

Apparently you commented the first .AcceptChanges away, so as far as I can tell it should work. You may however want to also remove the second .AcceptChanges, as .Update already does that. One thing you could check is that there isn't some other function or sub that calls .AcceptChanges before the user tries to update his order (this is a mistake I made once, and it took me weeks to finally figure out that I called .AcceptChanges somewhere else entirely).

The .Update method will actually implement all changes for you, also deleting rows, etc. If you want to give a user the chance to change his mind about deleting a row, you can just call .AcceptChanges, .Clear and then DataAdapter.fill(YourDataSet) if he chooses 'No' or .Update if he chooses 'Yes'.

Hope this helps,

Johan



My advice is free, and you may get what you paid for.

GeneralRe: Datagrid view to DataBase - Update Pin
Trupti Mehta8-Aug-07 0:33
Trupti Mehta8-Aug-07 0:33 
GeneralRe: Datagrid view to DataBase - Update Pin
Johan Hakkesteegt8-Aug-07 22:49
Johan Hakkesteegt8-Aug-07 22:49 
GeneralRe: Datagrid view to DataBase - Update Pin
Trupti Mehta9-Aug-07 1:02
Trupti Mehta9-Aug-07 1:02 
Questioncrystal reportviewr problem Pin
magedhv4-Aug-07 22:04
magedhv4-Aug-07 22:04 
AnswerRe: crystal reportviewr problem Pin
Rupesh Kumar Swami6-Aug-07 0:57
Rupesh Kumar Swami6-Aug-07 0:57 
QuestionDecimal Point Pin
WestSideRailways4-Aug-07 19:22
WestSideRailways4-Aug-07 19:22 
AnswerRe: Decimal Point Pin
Luc Pattyn5-Aug-07 0:13
sitebuilderLuc Pattyn5-Aug-07 0:13 
GeneralRe: Decimal Point Pin
WestSideRailways5-Aug-07 9:44
WestSideRailways5-Aug-07 9:44 
GeneralRe: Decimal Point Pin
Luc Pattyn5-Aug-07 10:07
sitebuilderLuc Pattyn5-Aug-07 10:07 
QuestionDatagridview Comboboxs Pin
ryan1174-Aug-07 11:19
ryan1174-Aug-07 11:19 
QuestionWhich programing Language is best for me? Pin
Benjamin Dodd4-Aug-07 9:40
Benjamin Dodd4-Aug-07 9:40 
AnswerRe: Which programing Language is best for me? Pin
Rareed4-Aug-07 10:18
Rareed4-Aug-07 10:18 
GeneralRe: Which programing Language is best for me? Pin
Benjamin Dodd4-Aug-07 10:22
Benjamin Dodd4-Aug-07 10:22 
GeneralRe: Which programing Language is best for me? Pin
The ANZAC4-Aug-07 12:52
The ANZAC4-Aug-07 12:52 
GeneralRe: Which programing Language is best for me? Pin
Colin Angus Mackay4-Aug-07 12:58
Colin Angus Mackay4-Aug-07 12:58 
GeneralRe: Which programing Language is best for me? Pin
Christian Graus4-Aug-07 13:28
protectorChristian Graus4-Aug-07 13:28 
GeneralRe: Which programing Language is best for me? Pin
Mohammed Hameed5-Aug-07 9:52
professionalMohammed Hameed5-Aug-07 9:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.