Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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.

Posted

I tried that and it doesn't seem to make a difference. I am not getting an error message, the query either doesn't run or doesn't 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 don't know what I am doing wrong.

  • 3 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...