Hi Guys
I am having an issue which for the life of me I cannot recreate on my testing environment, and my client only gets it once in a while. For example, she has captured 30 new members this week, and she only got it once after doing it for those 30 times.
It's an application I am maintaining and editing, so if anything looks wrong in the code, please feel free to tell me.
Here's the code block that the exception is thrown in:
Any advice here would be very much appreciated.
I am having an issue which for the life of me I cannot recreate on my testing environment, and my client only gets it once in a while. For example, she has captured 30 new members this week, and she only got it once after doing it for those 30 times.
It's an application I am maintaining and editing, so if anything looks wrong in the code, please feel free to tell me.
Here's the code block that the exception is thrown in:
Code:
Public Sub addMemberOptionalField(ByVal sMemNo As String, _
ByVal sField As String, _
ByVal sValue As String, _
ByVal AccPacPassword As String, _
ByVal bUpdate As Boolean)
Dim exSession As ACCPACXAPILib.xapiSession
exSession = New ACCPACXAPILib.xapiSession
Dim reader As New AppSettingsReader
Dim dbname As String = reader.GetValue("DBName", GetType(String)).ToString()
Try
exSession.Open("ADMIN", AccPacPassword, dbname, Now, 0)
Dim temp As Boolean
Dim ARCUSTOMER1header As ACCPACXAPILib.xapiView
Dim ARCUSTOMER1headerFields As ACCPACXAPILib.xapiFields
ARCUSTOMER1header = exSession.OpenView("AR0024", "AR")
ARCUSTOMER1headerFields = ARCUSTOMER1header.Fields
Dim ARCUSTOMER1detail As ACCPACXAPILib.xapiView
Dim ARCUSTOMER1detailFields As ACCPACXAPILib.xapiFields
ARCUSTOMER1detail = exSession.OpenView("AR0400", "AR")
ARCUSTOMER1detailFields = ARCUSTOMER1detail.Fields
ARCUSTOMER1header.Compose(ARCUSTOMER1detail)
ARCUSTOMER1detail.Compose(ARCUSTOMER1header)
temp = ARCUSTOMER1header.Exists
ARCUSTOMER1header.Init()
ARCUSTOMER1headerFields.Item("IDCUST").Value = sMemNo ' Customer Number
ARCUSTOMER1header.Read()
If Not bUpdate Then
temp = ARCUSTOMER1detail.Exists
ARCUSTOMER1detail.RecordClear()
temp = ARCUSTOMER1detail.Exists
ARCUSTOMER1detail.RecordGenerate(False)
ARCUSTOMER1detailFields.Item("IDCUST").Value = sMemNo
ARCUSTOMER1detailFields.Item("OPTFIELD").PutWithoutVerification(sField) ' Optional Field
ARCUSTOMER1detailFields.Item("VALIFTEXT").Value = sValue ' Text Value
ARCUSTOMER1detail.Insert()
Else
ARCUSTOMER1detailFields.Item("IDCUST").Value = sMemNo
ARCUSTOMER1detailFields.Item("OPTFIELD").PutWithoutVerification(sField) ' Optional Field
ARCUSTOMER1detail.Read()
ARCUSTOMER1detailFields.Item("VALIFTEXT").Value = sValue ' Text Value
ARCUSTOMER1detail.Update()
End If
ARCUSTOMER1detail.Read()
ARCUSTOMER1header.Update()
Catch ex As Exception
MsgBox(ex.Message & " " & GetAccpacError(exSession), MsgBoxStyle.Critical, "Save Optional Fields")
Finally
exSession.Close()
exSession = Nothing
End Try
End Sub
Any advice here would be very much appreciated.