G
Guest
Property Value Changes Value between calls
In frmTopicFromStart I call a procedure in clsDataChor to retrieve the autoincrementing ID for the topic. I place it in a textbox and also put it in a public variable in btnSaveTabGeneral:
clsDChor.TransferID(txtID, iTopicID)
MsgBox("btn savetabgeneral " & iTopicID.ToString)
The message box shows the correct value(according to the access data base, 71, as of the last run.
In another tab I select topic test and click the QuickWordButton. The msgbox in quickword event handler also shows 71:
Dim frm As New frmQuickWord
frm.sQuick = str1
MsgBox("btnquickword " & iTopicID.ToString)
frm.KSID = iTopicID
frm.ShowDialog()
KSID is a property in frmQuickWord and also shows 71, as it should, in the form_load event:
Private Sub frmQuickWord_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
txtQuickWord.Text = sQuick.Trim
cnQWKS.ConnectionString = gstrConn
MsgBox("quickwordload " & KSID.ToString)
End Sub
Now the problem comes. There's a textbox with the selected text from the quickword button in frmtopicfromstart: This is used to add a row to the keywordsets table, the keywords table, and the searchphrase table. No problem:
daQWKS.Fill(DsQWKS1, "KeywordSets")
Dim tblKS As New dsQWKS.KeywordSetsDataTable
Dim rowKS As dsQWKS.KeywordSetsRow
Try
rowKS = tblKS.NewKeywordSetsRow()
Catch ex As Exception
MessageBox.Show("Type = " & ex.GetType.ToString & vbCr & "Message = " & ex.Message)
End Try
rowKS.Active = True
rowKS.KeywordSet = txtQuickWord.Text 'sQuick
'rowKS.ID = -1
Try
tblKS.AddKeywordSetsRow(rowKS)
daQWKS.InsertCommand = New OleDb.OleDbCommand("INSERT INTO KeywordSets(Active, KeywordSet) values (?,?)", cnQWKS)
daQWKS.InsertCommand.Parameters.Add("@Active", OleDb.OleDbType.Boolean, 2, "Active")
daQWKS.InsertCommand.Parameters.Add("KeywordSet", OleDb.OleDbType.VarWChar, 16, "KeywordSet")
AddHandler daQWKS.RowUpdated, AddressOf OnRowUpDated
Catch ex As Exception
MessageBox.Show("Type = " & ex.GetType.ToString & vbCr & "Message = " & ex.Message)
End Try
Try
Dim intModified As Integer
intModified = daQWKS.Update(tblKS)
Dim sOutput As String
sOutput = "Modified " & intModified & " KeywordSet(s)"
'MessageBox.Show(sOutput, "Update succeeded!", MessageBoxButtons.OK, MessageBoxIcon.Information)
Catch ex As Exception
MessageBox.Show("Type = " & ex.GetType.ToString & vbCr & "Message = " & ex.Message)
End Try
daQWK.Fill(DsQWKS1, "Keywords")
Dim tblK As New dsQWKS.KeywordsDataTable
Dim rowK As dsQWKS.KeywordsRow
Try
rowK = tblK.NewKeywordsRow
Catch ex As Exception
MessageBox.Show("Type = " & ex.GetType.ToString & vbCr & "Message = " & ex.Message)
End Try
rowK.Active = True
rowK.Keyword = txtQuickWord.Text 'sQuick 'rowKS.ID = -1
rowK.KeywordSetID = KSID
Try
tblK.AddKeywordsRow(rowK)
daQWK.InsertCommand = New OleDb.OleDbCommand("INSERT INTO Keywords(Active, Keyword,KeywordSetID) values (?,?,?)", cnQWKS)
daQWK.InsertCommand.Parameters.Add("@Active", OleDb.OleDbType.Boolean, 2, "Active")
daQWK.InsertCommand.Parameters.Add("Keyword", OleDb.OleDbType.VarWChar, 16, "Keyword")
daQWK.InsertCommand.Parameters.Add("KeywordSetID", OleDb.OleDbType.Integer, 4, "KeywordSetID")
Catch ex As Exception
MessageBox.Show("Type = " & ex.GetType.ToString & vbCr & "Message = " & ex.Message)
End Try
Try
'Dim intModified As Integer
'intModified =
daQWK.Update(tblK)
'Dim sOutput As String
'sOutput = "Modified " & intModified & " Keyword(s)"
'MessageBox.Show(sOutput, "Update succeeded!", MessageBoxButtons.OK, MessageBoxIcon.Information)
Catch ex As Exception
MessageBox.Show("Type = " & ex.GetType.ToString & vbCr & "Message = " & ex.Message)
End Try
daQWSP.Fill(DsQWKS1, "SearchPhrase")
Dim tblSP As New dsQWKS.SearchPhraseDataTable
Dim rowSP As dsQWKS.SearchPhraseRow
Try
rowSP = tblSP.NewSearchPhraseRow
Catch ex As Exception
MessageBox.Show("Type = " & ex.GetType.ToString & vbCr & "Message = " & ex.Message)
End Try
rowSP.Active = True
rowSP.SearchPhrase = txtQuickWord.Text 'sQuick 'rowKS.ID = -1
rowSP.KeywordSetID = KSID
Try
tblSP.AddSearchPhraseRow(rowSP)
daQWSP.InsertCommand = New OleDb.OleDbCommand("INSERT INTO SearchPhrase(Active, SearchPhrase,KeywordSetID) values (?,?,?)", cnQWKS)
daQWSP.InsertCommand.Parameters.Add("@Active", OleDb.OleDbType.Boolean, 2, "Active")
daQWSP.InsertCommand.Parameters.Add("SearchPhrase", OleDb.OleDbType.VarWChar, 16, "SearchPhrase")
daQWSP.InsertCommand.Parameters.Add("KeywordSetID", OleDb.OleDbType.Integer, 4, "KeywordSetID")
Catch ex As Exception
MessageBox.Show("Type = " & ex.GetType.ToString & vbCr & "Message = " & ex.Message)
End Try
Try
'Dim intModified As Integer
'intModified =
daQWSP.Update(tblSP)
'Dim sOutput As String
'sOutput = "Modified " & intModified & " Keyword(s)"
'MessageBox.Show(sOutput, "Update succeeded!", MessageBoxButtons.OK, MessageBoxIcon.Information)
Catch ex As Exception
MessageBox.Show("Type = " & ex.GetType.ToString & vbCr & "Message = " & ex.Message)
End Try
There is one more table to update, the KeywordSetAssignments table, which tells me in which table the keywordset and other tables are assigned.(I do an indexing of all tables elsewhere).
Here is part of the code for the last table:
daKSTA.Fill(DsQWKS1, "KeywordSetAssignments")
Dim tblKSTA As New dsQWKS.KeywordSetAssignmentsDataTable
Dim rowKSTA As dsQWKS.KeywordSetAssignmentsRow
Try
rowKSTA = tblKSTA.NewKeywordSetAssignmentsRow
Catch ex As Exception
MessageBox.Show("Type = " & ex.GetType.ToString & vbCr & "Message = " & ex.Message)
End Try
rowKSTA.BeginText = 0
Dim frm As New frmTopicFromStart
rowKSTA.TopicID = KSID
MsgBox("Btn save and close " & " TopicID " & rowKSTA.TopicID.ToString)
rowKSTA.KeywordSetID = KSID
The msgbox showed 111, and naturally the update for this table failed because there wasn't a corresponding table in topics. This happens every time and it's frustrating. Similar code works in many places elsewhere in the app.
Can anybody tell me what's wrong.
polynomial5d
In frmTopicFromStart I call a procedure in clsDataChor to retrieve the autoincrementing ID for the topic. I place it in a textbox and also put it in a public variable in btnSaveTabGeneral:
clsDChor.TransferID(txtID, iTopicID)
MsgBox("btn savetabgeneral " & iTopicID.ToString)
The message box shows the correct value(according to the access data base, 71, as of the last run.
In another tab I select topic test and click the QuickWordButton. The msgbox in quickword event handler also shows 71:
Dim frm As New frmQuickWord
frm.sQuick = str1
MsgBox("btnquickword " & iTopicID.ToString)
frm.KSID = iTopicID
frm.ShowDialog()
KSID is a property in frmQuickWord and also shows 71, as it should, in the form_load event:
Private Sub frmQuickWord_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
txtQuickWord.Text = sQuick.Trim
cnQWKS.ConnectionString = gstrConn
MsgBox("quickwordload " & KSID.ToString)
End Sub
Now the problem comes. There's a textbox with the selected text from the quickword button in frmtopicfromstart: This is used to add a row to the keywordsets table, the keywords table, and the searchphrase table. No problem:
daQWKS.Fill(DsQWKS1, "KeywordSets")
Dim tblKS As New dsQWKS.KeywordSetsDataTable
Dim rowKS As dsQWKS.KeywordSetsRow
Try
rowKS = tblKS.NewKeywordSetsRow()
Catch ex As Exception
MessageBox.Show("Type = " & ex.GetType.ToString & vbCr & "Message = " & ex.Message)
End Try
rowKS.Active = True
rowKS.KeywordSet = txtQuickWord.Text 'sQuick
'rowKS.ID = -1
Try
tblKS.AddKeywordSetsRow(rowKS)
daQWKS.InsertCommand = New OleDb.OleDbCommand("INSERT INTO KeywordSets(Active, KeywordSet) values (?,?)", cnQWKS)
daQWKS.InsertCommand.Parameters.Add("@Active", OleDb.OleDbType.Boolean, 2, "Active")
daQWKS.InsertCommand.Parameters.Add("KeywordSet", OleDb.OleDbType.VarWChar, 16, "KeywordSet")
AddHandler daQWKS.RowUpdated, AddressOf OnRowUpDated
Catch ex As Exception
MessageBox.Show("Type = " & ex.GetType.ToString & vbCr & "Message = " & ex.Message)
End Try
Try
Dim intModified As Integer
intModified = daQWKS.Update(tblKS)
Dim sOutput As String
sOutput = "Modified " & intModified & " KeywordSet(s)"
'MessageBox.Show(sOutput, "Update succeeded!", MessageBoxButtons.OK, MessageBoxIcon.Information)
Catch ex As Exception
MessageBox.Show("Type = " & ex.GetType.ToString & vbCr & "Message = " & ex.Message)
End Try
daQWK.Fill(DsQWKS1, "Keywords")
Dim tblK As New dsQWKS.KeywordsDataTable
Dim rowK As dsQWKS.KeywordsRow
Try
rowK = tblK.NewKeywordsRow
Catch ex As Exception
MessageBox.Show("Type = " & ex.GetType.ToString & vbCr & "Message = " & ex.Message)
End Try
rowK.Active = True
rowK.Keyword = txtQuickWord.Text 'sQuick 'rowKS.ID = -1
rowK.KeywordSetID = KSID
Try
tblK.AddKeywordsRow(rowK)
daQWK.InsertCommand = New OleDb.OleDbCommand("INSERT INTO Keywords(Active, Keyword,KeywordSetID) values (?,?,?)", cnQWKS)
daQWK.InsertCommand.Parameters.Add("@Active", OleDb.OleDbType.Boolean, 2, "Active")
daQWK.InsertCommand.Parameters.Add("Keyword", OleDb.OleDbType.VarWChar, 16, "Keyword")
daQWK.InsertCommand.Parameters.Add("KeywordSetID", OleDb.OleDbType.Integer, 4, "KeywordSetID")
Catch ex As Exception
MessageBox.Show("Type = " & ex.GetType.ToString & vbCr & "Message = " & ex.Message)
End Try
Try
'Dim intModified As Integer
'intModified =
daQWK.Update(tblK)
'Dim sOutput As String
'sOutput = "Modified " & intModified & " Keyword(s)"
'MessageBox.Show(sOutput, "Update succeeded!", MessageBoxButtons.OK, MessageBoxIcon.Information)
Catch ex As Exception
MessageBox.Show("Type = " & ex.GetType.ToString & vbCr & "Message = " & ex.Message)
End Try
daQWSP.Fill(DsQWKS1, "SearchPhrase")
Dim tblSP As New dsQWKS.SearchPhraseDataTable
Dim rowSP As dsQWKS.SearchPhraseRow
Try
rowSP = tblSP.NewSearchPhraseRow
Catch ex As Exception
MessageBox.Show("Type = " & ex.GetType.ToString & vbCr & "Message = " & ex.Message)
End Try
rowSP.Active = True
rowSP.SearchPhrase = txtQuickWord.Text 'sQuick 'rowKS.ID = -1
rowSP.KeywordSetID = KSID
Try
tblSP.AddSearchPhraseRow(rowSP)
daQWSP.InsertCommand = New OleDb.OleDbCommand("INSERT INTO SearchPhrase(Active, SearchPhrase,KeywordSetID) values (?,?,?)", cnQWKS)
daQWSP.InsertCommand.Parameters.Add("@Active", OleDb.OleDbType.Boolean, 2, "Active")
daQWSP.InsertCommand.Parameters.Add("SearchPhrase", OleDb.OleDbType.VarWChar, 16, "SearchPhrase")
daQWSP.InsertCommand.Parameters.Add("KeywordSetID", OleDb.OleDbType.Integer, 4, "KeywordSetID")
Catch ex As Exception
MessageBox.Show("Type = " & ex.GetType.ToString & vbCr & "Message = " & ex.Message)
End Try
Try
'Dim intModified As Integer
'intModified =
daQWSP.Update(tblSP)
'Dim sOutput As String
'sOutput = "Modified " & intModified & " Keyword(s)"
'MessageBox.Show(sOutput, "Update succeeded!", MessageBoxButtons.OK, MessageBoxIcon.Information)
Catch ex As Exception
MessageBox.Show("Type = " & ex.GetType.ToString & vbCr & "Message = " & ex.Message)
End Try
There is one more table to update, the KeywordSetAssignments table, which tells me in which table the keywordset and other tables are assigned.(I do an indexing of all tables elsewhere).
Here is part of the code for the last table:
daKSTA.Fill(DsQWKS1, "KeywordSetAssignments")
Dim tblKSTA As New dsQWKS.KeywordSetAssignmentsDataTable
Dim rowKSTA As dsQWKS.KeywordSetAssignmentsRow
Try
rowKSTA = tblKSTA.NewKeywordSetAssignmentsRow
Catch ex As Exception
MessageBox.Show("Type = " & ex.GetType.ToString & vbCr & "Message = " & ex.Message)
End Try
rowKSTA.BeginText = 0
Dim frm As New frmTopicFromStart
rowKSTA.TopicID = KSID
MsgBox("Btn save and close " & " TopicID " & rowKSTA.TopicID.ToString)
rowKSTA.KeywordSetID = KSID
The msgbox showed 111, and naturally the update for this table failed because there wasn't a corresponding table in topics. This happens every time and it's frustrating. Similar code works in many places elsewhere in the app.
Can anybody tell me what's wrong.
polynomial5d