-
update help
There's probably something obvious I'm missing here, but I can't get this code to update my Access table...
Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
If (rb1Y.Checked Or rb1N.Checked) Then
Response.Redirect("orientationB.aspx")
Else
'advise of error
l blError.Text = ">> There is at least one Yes/No question left unanswered. Please review. <<"
Exit Sub
End If
'update answer table
If rb1Y.Checked Then
DsAnsOA1.Tables("tableOAAns").Rows(0).Item(1) = "yes"
Else
DsAnsOA1.Tables("tableOAAns").Rows(0).Item(1) = "no"
End If
DsAnsOA1.Tables("tableOAAns").Rows(0).Item(2) = tb2.Text
DsAnsOA1.Tables("tableOAAns").Rows(0).Item(3) = tb3.Text
DsAnsOA1.Tables("tableOAAns").Rows(0).Item(4) = tb4.Text
daA.Update(DsAnsOA1)
Catch ex As Exception
Finally
' nothing here yet
End Try
End Sub
can anyone give me a clue?...
thanks much...Ooogs
-
Your code is never actually getting to the database part. It either redirects or exits the sub.
-
I revised it a bit...
Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
If (rb1Y.Checked Or rb1N.Checked) Then
'update answer table
If rb1Y.Checked Then
DsAnsOA1.Tables("tableOAAns").Rows(0).Item(0) = "yes"
ElseIf Not rb1Y.Checked Then
DsAnsOA1.Tables("tableOAAns").Rows(0).Item(0) = "no"
End If
DsAnsOA1.Tables("tableOAAns").Rows(0).Item(1) = tb2.Text
DsAnsOA1.Tables("tableOAAns").Rows(0).Item(2) = tb3.Text
DsAnsOA1.Tables("tableOAAns").Rows(0).Item(3) = tb4.Text
daA.Update(DsAnsOA1)
Response.Redirect("orientationB.aspx")
Else
'advise of error
lblError.Text = ">> There is at least one Yes/No question left unanswered. Please review. <<"
Exit Sub
End If
Catch ex As Exception
Finally
End Try
End Sub
...but it doesn't ever seem to get to the response.redirect command. It never leaves the page. Can anyone see what I'm missing?
Thanks...Ooogs
-
On your catch block, put a break in with the IDE, then run your code. Figure out what the exception is.
-
No exception is being thrown. It's just not advancing to the redirected page.
-
How about stepping through each line in debug mode. Find out if you are even processing the Response.Redirect line. It looks right to me, as long as there is a page by the orientationB.aspx name in the same folder.