Thank you to many great programmers in this group who are helping to get the Poll/Survey application to this far:
Questions chain:
http://www.aspforums.net/Threads/196837/ASPNet-Error-Response-is-not-available-in-this-context/
http://www.aspforums.net/Threads/203805/Poll-survey---Not-allow-the-same-person-to-vote-twice-o/
I ran into the Insert conflict error "The INSERT statement conflicted with the FOREIGN KEY constraint "fk_UserId". The conflict occurred in database "Demo_Voting", table "dbo.Users", column 'UserId'.The statement has been terminated."
It's poiting :
It’s pointing this line:
Line 65: cmd.ExecuteNonQuery()
From Protected Sub OnOptionChanged function
Protected Sub OnOptionChanged(ByVal sender As Object, ByVal e As EventArgs)
Dim constr As String = ConfigurationManager.ConnectionStrings("constr").ConnectionString
Dim con As SqlConnection = New SqlConnection(constr)
Dim cmd As SqlCommand = New SqlCommand("SavePollAnswer", con)
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.AddWithValue("@PollId", 1)
cmd.Parameters.AddWithValue("@PollAnswer", rblPollOptions.SelectedValue)
cmd.Parameters.AddWithValue("@UserId", CType(Me.Session("UserDetails"), User).UserId)
con.Open()
cmd.ExecuteNonQuery()
con.Close()
Response.Redirect(Request.Url.AbsoluteUri)
End Sub
Can you help to see why SavePollAnswer stored procedure caused the conflict? Thanks again for great help!