0
我有點糊塗了這個代碼,我不知道我在哪裏做的不對返回詳細,後的IDataReader = DbObject.ExecuteReader(的DbCommand)第二次執行
Public Function CreateAddressDetailDb(ByVal AddressDetailList As IList(Of AddressDetail), ByVal EmployeeID As Integer) As String
Dim ReturnCode As Boolean = False
Dim Employeegeneratednumber As String = String.Empty
Dim ReturnValues As New Dictionary(Of String, Object)
Dim DbObject As Database = DatabaseFactory.CreateDatabase()
Dim DbCommand As DbCommand = DbObject.GetStoredProcCommand("usp_AddressDetial_Create")
Try
If Not AddressDetailList Is Nothing And AddressDetailList.Count > 0 Then
For Each Addressdetaulobject As AddressDetail In AddressDetailList
With Addressdetaulobject
Data.AddInParameter(DbCommand, "paEmployeeID", DbType.Int32, EmployeeID, DbObject)
Data.AddInParameter(DbCommand, "paUpdatedBy", DbType.Int16, .Updatedby, DbObject)
End With
Using DataReaderObject As IDataReader = DbObject.ExecuteReader(DbCommand)
DataReaderObject.Read()
ReturnValues("Result") = DataReaderObject.Item("Result")
ReturnValues("Employeenumber") = DataReaderObject.Item("Employeenumber")
DataReaderObject.Close()
If Employeegeneratednumber = String.Empty Or Employeegeneratednumber = "" Then
Employeegeneratednumber = CType(ReturnValues("Employeenumber"), String)
End If
End Using
DbCommand.Parameters.Clear()
Next
End If
If ReturnValues("Result").ToString().Equals("0") Then
Return Employeegeneratednumber
Else
Return String.Empty
End If
Catch ex As System.Exception
Throw
End Try
Return Employeegeneratednumber
End Function
當我插入一個Employee
1個地址我得到正確的Employeegeneratednumber
,但如果插入Employee
與2個地址,然後我得到舊的Employeegeneratednumber
這是與當前員工無關。 此問題只發生在不在開發站點上的生產站點
當我試圖插入address1然後獲得employeenumber = 10,當我嘗試插入地址2爲同一名僱員時,我得到錯誤的僱傭號碼。我在這裏通過同一名員工的地址列表 –