I have inherited a system written in VB .NET. I am not good with it or ADO. I have a program that updates a field in a table conditional on the value of another field in the same table. I understand it, but only just. Snippet attached.
I need to change it conditional on the value of a field in an unrelated table. In short, I want to see if a person exists in the Persons table (by their firstname and familyname) and if so, update the RegistrationExpiryDate, RegistrationStatus, and CurrentRegistrationKey fiels in the SysConfig table.
Any help will get my undying gratitude as well as the points.
Thanks in advance.
Dim objDs As DataSet
Dim ObjDa As OleDbDataAdapter
Dim objRow As DataRow
Dim objTable As DataTable
Dim objColumn As DataColumn
Dim MsgTitle As String = "Celebrant Assist Registration. "
Dim sSQL As String = "Select * from SysConfig"
Dim MySQL As String = _
"UPDATE SysConfig SET RegistrationExpiryDate = #12/31/2020#, " & _
"RegistrationStatus = 'Registered', " & _
"CurrentRegistrationKey = '7B12-2F4A-FD8F-34B4' " & _
"WHERE CurrentRegistrationRequest = '" & RequestNo & "'"
Dim MyConnection As New OleDb.OleDbConnection(ConnectStr)
Label1.Text = "Request Number: " & RequestNo
objDs = New DataSet
'Connect to database and specify sSQL
ObjDa = New OleDbDataAdapter(sSQL, ConnectStr)
For Each objRow In objDs.Tables(0).Rows
If objRow("CurrentRegistrationRequest").ToString = RequestNo Then
Dim MyCommand As New OleDb.OleDbCommand(MySQL, MyConnection)
Label2.Text = "Celebrant Assist has been successfully registered."
Label2.Text = "The Request Numbers do not Match. " & CrLf & "Please contact Celebrant Assist Support"
'Like Setting to Nothing
Catch objException As Exception
MsgBox("Registration Error. Please contact Celebrant Assist Support. " & CrLf & _
objException.ToString, , MsgTitle)