Can someone please take a look at this code and tell me what I am doing
wrong???
I am getting the following error:
----------------------------------------------------
Object reference not set to an instance of an object.
--------------------------------------------------
at this line:
---------------------------------------------------------
objNewRow = objTable.NewRow ()
------------------------------------------------
Dim FirstName As String = Session("FirstN ame")
Dim LastName As String = Session("LastNa me")
Dim DOB As String = Session("DOB")
Dim ResponseDate As String = Now()
Dim SponsorCode As String = Session("Sponso rCode")
'Dim counter As Integer
' Dim arr() As String
' Dim coll As NameValueCollec tion
' coll = Request.Form
'arr = coll.AllKeys
'For counter = 0 To arr.GetUpperBou nd(0)
'Response.Write ("Form: " & arr(counter) & "<br>")
Dim answer As String
Dim AnsStr
For Each answer In Request.Form
'references to answer return the name of the item
If (answer = "__VIEWSTAT E") Or (answer = "Button1") Then
Else
Dim strConnection As String = Myconnection
Dim StrSQL As String = "Select ResponseID, ResponseDate,
LastName, FirstName, DOB, SponsorCode, QuestionID, QResponse from
EligibilityResp onse"
Dim objDataSet As New DataSet
Dim objConnection As OleDbConnection
Dim objAdapter As OleDbDataAdapte r
Dim objCommand As OleDbCommand
Dim objBuilder As OleDbCommandBui lder
objConnection = New OleDbConnection (strConnection)
objAdapter = New OleDbDataAdapte r(StrSQL, objConnection)
objBuilder = New OleDbCommandBui lder(objAdapter )
objAdapter.Inse rtCommand = objBuilder.GetI nsertCommand()
Dim objTable As DataTable
Dim objNewRow As DataRow
objTable = objDataSet.Tabl es("Eligibility Response")
objNewRow = objTable.NewRow ()
objNewRow("Resp onseDate") = ResponseDate
objNewRow("Last Name") = LastName
objNewRow("Firs tName") = FirstName
objNewRow("DOB" ) = DOB
objNewRow("Spon sorCode") = SponsorCode
objNewRow("Ques tionID") = answer
objNewRow("QRes ponse") = Request.Form(an swer)
objTable.Rows.A dd(objNewRow)
AnsStr = AnsStr & "the answer to question " & answer & "
is " & Request.Form(an swer) & " " & FirstName & " " & LastName & " " &
DOB & " " & ResponseDate & " " & SponsorCode & " <br>"
End If
Next
Label1.Text = AnsStr
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!