Record Counter Error

Results 1 to 2 of 2

Thread: Record Counter Error

  1. #1
    Gonzalo Paternoster Guest

    Default Record Counter Error

    I have the following code on my page to do a counter for a recorded being requested to keep track of how many times it has been requestion in the table bizop2 I have a field call counter and it is set to int<BR><BR>set R = C.execute(Q)<BR>newcount = cInt(R("counter")) + 1<BR> <BR>Q = "UPDATE bizop2 SET counter = " & newcount & " WHERE id = &#039id&#039"<BR>C.Execute(Q)<BR><BR>I get the following error:<BR><BR>Microsoft OLE DB Provider for ODBC Drivers error &#039 80040e07&#039 <BR><BR>[Microsoft][ODBC SQL Server Driver][SQL Server]Syntax error converting the varchar value &#039id&#039 to a column of data type int. <BR><BR>/bizop_extnd22.asp, line 65

  2. #2
    Join Date
    Dec 1969

    Default RE: Record Counter Error

    &nbsp;<BR>*READ* what the error message says:<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;Syntax error converting the varchar<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb sp;value &#039id&#039 to a column of data type int. <BR><BR>That message should tell you two things:<BR><BR>(1) You are trying to use a string in &#039...&#039 marks to set the value of a NUMERIC field. This is not allowed in SQL. Numeric values have *NO* special characters surrounding them.<BR><BR>(2) In any case, you seem to be trying to set the field value to &#039id&#039. But wouldn&#039t you *expect* that you would want to set it to something like &#039 17&#039 or &#039 378&#039 or whatever? (Except that you want to do that *without* the &#039...&#039 marks!)<BR><BR>I presume that this is an oversight on your part, since you are able to make a query and then an update. So I can only suggest that next time you read the error message and try to interpret it. Most of the MS error messages do give real info.<BR><BR>So, in any case, you need to modify your code to this:<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;Q = "UPDATE bizop2 SET counter = " & newcount & " WHERE id = " & id <BR>&nbsp;&nbsp;&nbsp;&nbsp;C.Execute(Q)<BR><BR> I don&#039t know where you get/will get the value of id from. Presumably it is another field in the DB, so you could probably simply do<BR>&nbsp;&nbsp;&nbsp;&nbsp;Q = "UPDATE bizop2 SET counter = " & newcount & " WHERE id = " & RS("id")<BR><BR>***********<BR><BR>Bill Wilkinson<BR><BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;C.Exe cute(Q)<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts