G
Guest
Why textboxes don't go blank when I click addnew.
I have a FullWord form displaying KeywordSets in textboxes and a checkbox, a
grid in synch with the textboxes, and two child grids tied by relationships
to KeywordSets. One is Keywords and the other is SearchPhrase.
I have several problems with this form, but here I'll ask for help on just
one. I have 15 or so forms similar to this and when I click the add button it
works in all forms except this one. It may or may not have something to do
with the child grids. I doubt it, because edit works fine.
down to details
Everything is set up as usual in the form_load event:
Private Sub frmFullWord_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Try
cnWKS.ConnectionString = gstrconn
cm = CType(BindingContext(dsWKS1, "KeyWordSets"), CurrencyManager)
AddHandler cm.ItemChanged, AddressOf cm_ItemChanged
AddHandler cm.PositionChanged, AddressOf cm_PositionChanged
AddHandler daWKS.RowUpdated, AddressOf OnRowUpDated
cmK = CType(BindingContext(dsWKS1,
"KeywordSets.KeywordSetsKeywords"), CurrencyManager)
cmSP = CType(BindingContext(dsWKS1,
"KeywordSets.KeywordSetsSearchPhrase"), CurrencyManager)
daWKS.Fill(dsWKS1, "KeywordSets")
daWK.Fill(dsWKS1, "Keywords")
daWSP.Fill(dsWKS1, "SearchPhrase")
Catch ex As OleDbException
If ex.Errors(0).SQLState = "3022" Then
MsgBox(ex.Errors(0).Message & s & "Please try again")
dsWKS1.Clear()
daWKS.Fill(dsWKS1, "KeywordSets")
daWK.Fill(dsWKS1, "Keywords")
daWSP.Fill(dsWKS1, "SearchPhrase")
Exit Try
Else
Dim errorMessages As String
errorMessages += "Message: " & ex.Errors(0).Message &
ControlChars.CrLf _
& "NativeError: " & ex.Errors(0).NativeError &
ControlChars.CrLf _
& "Source: " & ex.Errors(0).Source &
ControlChars.CrLf _
& "SQLState: " & ex.Errors(0).SQLState &
ControlChars.CrLf _
& "The form will be closed"
MsgBox(errorMessages)
Me.Close()
End If
Catch ex As DBConcurrencyException
MsgBox(ex.Message & s & "The dataset will be refreshed." & s &
"Then you can navigate to the row and update it again.")
dsWKS1.Clear()
daWKS.Fill(dsWKS1, "KeywordSets")
daWK.Fill(dsWKS1, "Keywords")
daWSP.Fill(dsWKS1, "SearchPhrase")
Exit Try
Catch ex As Exception
MsgBox(ex.GetType.ToString & s & ex.Message & s & ex.HelpLink &
s & ex.StackTrace & s & ex.Source & s & "The form will be closed") '& s &
ex.TargetSite)
Me.Close()
End Try
SetEditMode(False)
End Sub
Everything is filled and I can navigate backwards and forwards. I can
edit and delete KeywordSets. No error messages.
The add button procedure is as follows:
Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnAdd.Click
cm.AddNew()
SetEditMode(True)
End Sub
pretty run on the mill. Exactly the same as with the other forms that
all work.
The position starts at 1 of 3. If I press add it stays on 1 and says 1 of
4. In the associated grid (I also show a read only grid for keyword sets.
Synch is perfect as with the other forms) The 4th row shows at the bottom
with a keywordsetid, a checked active, and null for keywordset (name) and
description.
If I move the pointer in the grid to the 4th row, the position label still
says row 1 of 4 and the contents of the textboxes are the contents of the
first row.
If I click update (end edit) no error occurs. If I try to update the
dataadapter I get the message 'No changes to submit!'. The fourth row stays
in the grid and the position label says 1 of 4.
If I close and reopen there are only 3 rows, as expected. If I try to add
from say row 2 the exact same thing happens.
I take the schema from chapter 13 of ado.net core reference, which turns
out to have several severe errors in it that were corrected mostly by people
in the forums
Can anybody help?
dennis
I have a FullWord form displaying KeywordSets in textboxes and a checkbox, a
grid in synch with the textboxes, and two child grids tied by relationships
to KeywordSets. One is Keywords and the other is SearchPhrase.
I have several problems with this form, but here I'll ask for help on just
one. I have 15 or so forms similar to this and when I click the add button it
works in all forms except this one. It may or may not have something to do
with the child grids. I doubt it, because edit works fine.
down to details
Everything is set up as usual in the form_load event:
Private Sub frmFullWord_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Try
cnWKS.ConnectionString = gstrconn
cm = CType(BindingContext(dsWKS1, "KeyWordSets"), CurrencyManager)
AddHandler cm.ItemChanged, AddressOf cm_ItemChanged
AddHandler cm.PositionChanged, AddressOf cm_PositionChanged
AddHandler daWKS.RowUpdated, AddressOf OnRowUpDated
cmK = CType(BindingContext(dsWKS1,
"KeywordSets.KeywordSetsKeywords"), CurrencyManager)
cmSP = CType(BindingContext(dsWKS1,
"KeywordSets.KeywordSetsSearchPhrase"), CurrencyManager)
daWKS.Fill(dsWKS1, "KeywordSets")
daWK.Fill(dsWKS1, "Keywords")
daWSP.Fill(dsWKS1, "SearchPhrase")
Catch ex As OleDbException
If ex.Errors(0).SQLState = "3022" Then
MsgBox(ex.Errors(0).Message & s & "Please try again")
dsWKS1.Clear()
daWKS.Fill(dsWKS1, "KeywordSets")
daWK.Fill(dsWKS1, "Keywords")
daWSP.Fill(dsWKS1, "SearchPhrase")
Exit Try
Else
Dim errorMessages As String
errorMessages += "Message: " & ex.Errors(0).Message &
ControlChars.CrLf _
& "NativeError: " & ex.Errors(0).NativeError &
ControlChars.CrLf _
& "Source: " & ex.Errors(0).Source &
ControlChars.CrLf _
& "SQLState: " & ex.Errors(0).SQLState &
ControlChars.CrLf _
& "The form will be closed"
MsgBox(errorMessages)
Me.Close()
End If
Catch ex As DBConcurrencyException
MsgBox(ex.Message & s & "The dataset will be refreshed." & s &
"Then you can navigate to the row and update it again.")
dsWKS1.Clear()
daWKS.Fill(dsWKS1, "KeywordSets")
daWK.Fill(dsWKS1, "Keywords")
daWSP.Fill(dsWKS1, "SearchPhrase")
Exit Try
Catch ex As Exception
MsgBox(ex.GetType.ToString & s & ex.Message & s & ex.HelpLink &
s & ex.StackTrace & s & ex.Source & s & "The form will be closed") '& s &
ex.TargetSite)
Me.Close()
End Try
SetEditMode(False)
End Sub
Everything is filled and I can navigate backwards and forwards. I can
edit and delete KeywordSets. No error messages.
The add button procedure is as follows:
Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnAdd.Click
cm.AddNew()
SetEditMode(True)
End Sub
pretty run on the mill. Exactly the same as with the other forms that
all work.
The position starts at 1 of 3. If I press add it stays on 1 and says 1 of
4. In the associated grid (I also show a read only grid for keyword sets.
Synch is perfect as with the other forms) The 4th row shows at the bottom
with a keywordsetid, a checked active, and null for keywordset (name) and
description.
If I move the pointer in the grid to the 4th row, the position label still
says row 1 of 4 and the contents of the textboxes are the contents of the
first row.
If I click update (end edit) no error occurs. If I try to update the
dataadapter I get the message 'No changes to submit!'. The fourth row stays
in the grid and the position label says 1 of 4.
If I close and reopen there are only 3 rows, as expected. If I try to add
from say row 2 the exact same thing happens.
I take the schema from chapter 13 of ado.net core reference, which turns
out to have several severe errors in it that were corrected mostly by people
in the forums
Can anybody help?
dennis