Incrementing Database Field from RadioButtonList

lorena

Well-known member
Joined
Oct 23, 2003
Messages
134
Location
Phoenix, Arizona
I have an aspx form with a radiobuttonlist that a user can select from. When the user makes a choice and clicks "Submit", all I want to do is to go to that value in the currentTotal field and increment it by 1.
Here is my query:
strSQL = "Update SurveyResults SET CategoryTotal = CategoryTotal +1 " & _
"WHERE Category = ~ "
strSQL = Replace(strSQL, "~", strVal1)
I am using VS.Net and it does not like my query and does not update the database.
I am connecting (or trying to connect) to an Access db. The query works in access.
I think I am making this harder than it needs to be. I would appreciate any help.
 
try this...

strSQL = "Update SurveyResults SET CategoryTotal = CategoryTotal +1 " & _
"WHERE Category = " & strVal1 & ""
 
I tried that and it doesnt seem to make a difference. I am not getting an error message, the query either doesnt run or doesnt update the database.
Here is a simplified version (extra choices have been removed) of my code:
Public Sub btnSubmit_OnClick(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim itmSmoke As ListItem
Dim strTest As String
For Each itmSmoke In rblSmoke.Items
If itmSmoke.Value = "NoSm" Then
strCat = "NoSm"
End If
Next
BindData(strCat, strSubCat)
btnSubmit.Enabled = False
lblThanks.Visible = True
End Sub
Sub BindData(ByVal strVal1 As String)
Dim objConn As New OleDb.OleDbConnection(strConnString)
Dim objCommand As New OleDb.OleDbCommand(strSQL, objConn)
Dim objDS As New DataSet()
strSQL = "Update SurveyResults SET CategoryTotal = CategoryTotal +1 " & _
"WHERE Category = " & strVal1 & ""

objConn.Open()
objCommand.ExecuteNonQuery()
objConn.Close()
Label1.Text = "Record Updated"
End Sub
I just dont know what I am doing wrong.
 
Back
Top