lorena Posted June 7, 2005 Posted June 7, 2005 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. Quote
Moderators Robby Posted June 7, 2005 Moderators Posted June 7, 2005 try this... strSQL = "Update SurveyResults SET CategoryTotal = CategoryTotal +1 " & _ "WHERE Category = '" & strVal1 & "'" Quote Visit...Bassic Software
lorena Posted June 7, 2005 Author Posted June 7, 2005 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. Quote
lorena Posted June 7, 2005 Author Posted June 7, 2005 I think I found my problem. I had to move the "Dim objCommand" line to be run after the connection is open Quote
lorena Posted June 22, 2005 Author Posted June 22, 2005 Doh! I looked at that code and looked at it and didn't see the "." Thanks!! Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.