J
JenHu
Hi all,
I received an error: System.NullReferenceException: Object reference
not set to an instance of an object at GenerateA(String&
strEmpID, String& strClientAcct, String& strAcctStatus).
When I run the debug, and in the command line I entered ?strEmpID, and
it does passed the correct employee ID.
However, in the first line of the dataset,
EfundAcct = DS.Tables("AcctInfoTble").Rows(0)("DDACTNUM")
it generates error message "Object reference not set to an instance of
an object" and stacktrace is "at GenerateA(String& strEmpID,
String& strClientAcct, String& strAcctStatus)"
----------------------------------------------------
Main.vb
Main.VB
-----------------
some codes........
Dim strCurEmployId As String
strCurEmployId = dtrSelectTransactions("EmployID")
smCurBatch.WriteLine(GenerateA(strCurEmployId, boxTopCorp.Text,
"Open"))
some codes...............
------------------------------------------------
Public Function GenerateA(ByRef strEmpID As String, ByRef
strClientAcct As String, ByRef strAcctStatus As String)
Dim strResult As New System.Text.StringBuilder
Dim GPConnection As SqlConnection
Dim dr As SqlDataReader
Dim GPDataset As New DataSet
GPConnection = New
SqlConnection(".............................................")
Dim GPDataAdapter As New SqlDataAdapter("SELECT
LASTNAME,FRSTNAME,MIDLNAME,SOCSCNUM,ADDRESS1,PHONE1,BRTHDATE FROM
UPR00102 where EmployID= " + strEmpID, GPConnection)
Dim EfundAcct As String
Dim LName (30) As Char
Dim FName (30) As Char
Dim MName (30) As Char
GPConnection.Open()
GPDataAdapter.Fill(GPDataset, "AcctInfoTble")
Dim DS As DataSet = New DataSet
EfundAcct = DS.Tables("AcctInfoTble").Rows(0)("DDACTNUM")
LName = DS.Tables("AcctInfoTble").Rows(1).Item("LASTNAME")
FName = DS.Tables("AcctInfoTble").Rows(2)("LASTNAME")
MName = DS.Tables("AcctInfoTble").Rows(3)("MASTNAME")
'Position 1 2A A
strResult.Insert(0, "A ")
'Position 3 10A Employee Number
strResult.Insert(9, strEmpID.PadRight(10, " "))
'Position 13 16N Efund acct number
strResult.Insert(12, EfundAcct.PadLeft(16, " "))
GPConnection.Dispose()
Return strResult.ToString
End Function
*-----------------------*
Posted at:
www.GroupSrv.com
*-----------------------*
I received an error: System.NullReferenceException: Object reference
not set to an instance of an object at GenerateA(String&
strEmpID, String& strClientAcct, String& strAcctStatus).
When I run the debug, and in the command line I entered ?strEmpID, and
it does passed the correct employee ID.
However, in the first line of the dataset,
EfundAcct = DS.Tables("AcctInfoTble").Rows(0)("DDACTNUM")
it generates error message "Object reference not set to an instance of
an object" and stacktrace is "at GenerateA(String& strEmpID,
String& strClientAcct, String& strAcctStatus)"
----------------------------------------------------
Main.vb
Main.VB
-----------------
some codes........
Dim strCurEmployId As String
strCurEmployId = dtrSelectTransactions("EmployID")
smCurBatch.WriteLine(GenerateA(strCurEmployId, boxTopCorp.Text,
"Open"))
some codes...............
------------------------------------------------
Public Function GenerateA(ByRef strEmpID As String, ByRef
strClientAcct As String, ByRef strAcctStatus As String)
Dim strResult As New System.Text.StringBuilder
Dim GPConnection As SqlConnection
Dim dr As SqlDataReader
Dim GPDataset As New DataSet
GPConnection = New
SqlConnection(".............................................")
Dim GPDataAdapter As New SqlDataAdapter("SELECT
LASTNAME,FRSTNAME,MIDLNAME,SOCSCNUM,ADDRESS1,PHONE1,BRTHDATE FROM
UPR00102 where EmployID= " + strEmpID, GPConnection)
Dim EfundAcct As String
Dim LName (30) As Char
Dim FName (30) As Char
Dim MName (30) As Char
GPConnection.Open()
GPDataAdapter.Fill(GPDataset, "AcctInfoTble")
Dim DS As DataSet = New DataSet
EfundAcct = DS.Tables("AcctInfoTble").Rows(0)("DDACTNUM")
LName = DS.Tables("AcctInfoTble").Rows(1).Item("LASTNAME")
FName = DS.Tables("AcctInfoTble").Rows(2)("LASTNAME")
MName = DS.Tables("AcctInfoTble").Rows(3)("MASTNAME")
'Position 1 2A A
strResult.Insert(0, "A ")
'Position 3 10A Employee Number
strResult.Insert(9, strEmpID.PadRight(10, " "))
'Position 13 16N Efund acct number
strResult.Insert(12, EfundAcct.PadLeft(16, " "))
GPConnection.Dispose()
Return strResult.ToString
End Function
*-----------------------*
Posted at:
www.GroupSrv.com
*-----------------------*