Hi folks,
Again, I am trying to get VB.Net to do things I used to do in VB6, and as, usual, it has left me exasperated and sputtering curses.
The culprit, as usual, is ADO.NET.
I am having some trouble with dataset binding.
I have a form with a couple of text boxes for FirstName, MiddleName, and LastName.
I have a dataset dimensioned at the module level that pulls data in from MSSQL.
I open the dataset and I ask it for LastName
MsgBox(mdstMyData.Tables(0).Rows(0).Item("LastName"
) 'returns "Jones"
I bind firstname, lastname, and middlename to the dataset:
Me.LastName.DataBindings.Add("Text", mdstMyData.Tables(0), "LastName"
I change the data from "Jones" to "Smith". The changes appear on the form.
I press "Save" and the following code executes:
MsgBox(mdstMyData.Tables(0).Rows(0).RowState = DataRowState.Modified) 'returns false even though I can plainly see that the data changed
MsgBox(mdstMyData.Tables(0).Rows(0).Item("LastName"
) 'returns "Smith" exactly as the form looks
MsgBox(mdstMyData.Tables(0).Rows(0).RowState = DataRowState.Modified) ' still returns false
mdstMyData.Tables(0).Rows(0).Item("LastName"
= "Give us back ADO" 'I change the value in code
MsgBox(mdstMyData.Tables(0).Rows(0).Item("LastName"
) 'returns "Give us back ADO" - I appear to have changed the Dataset
MsgBox(mdstMyData.Tables(0).Rows(0).RowState = DataRowState.Modified) 'still returns false
Any ideas?
-Brian
Again, I am trying to get VB.Net to do things I used to do in VB6, and as, usual, it has left me exasperated and sputtering curses.
The culprit, as usual, is ADO.NET.
I am having some trouble with dataset binding.
I have a form with a couple of text boxes for FirstName, MiddleName, and LastName.
I have a dataset dimensioned at the module level that pulls data in from MSSQL.
I open the dataset and I ask it for LastName
MsgBox(mdstMyData.Tables(0).Rows(0).Item("LastName"
I bind firstname, lastname, and middlename to the dataset:
Me.LastName.DataBindings.Add("Text", mdstMyData.Tables(0), "LastName"
I change the data from "Jones" to "Smith". The changes appear on the form.
I press "Save" and the following code executes:
MsgBox(mdstMyData.Tables(0).Rows(0).RowState = DataRowState.Modified) 'returns false even though I can plainly see that the data changed
MsgBox(mdstMyData.Tables(0).Rows(0).Item("LastName"
MsgBox(mdstMyData.Tables(0).Rows(0).RowState = DataRowState.Modified) ' still returns false
mdstMyData.Tables(0).Rows(0).Item("LastName"
MsgBox(mdstMyData.Tables(0).Rows(0).Item("LastName"
MsgBox(mdstMyData.Tables(0).Rows(0).RowState = DataRowState.Modified) 'still returns false
Any ideas?
-Brian