Using Forwardslash to divide in SQL Query

Results 1 to 2 of 2

Thread: Using Forwardslash to divide in SQL Query

  1. #1
    Join Date
    Dec 1969

    Default Using Forwardslash to divide in SQL Query

    I was using this query in a classic asp page, but now that I have put it into .net, I get an error becuase of the forwardslash (/) divisor. Compiler Error Message: BC30452: Operator &#039;/&#039; is not defined for types &#039;System.Data.SqlClient.SqlCommand&#039; and &#039;Long&#039;. Can I not do this in .dotnet?<BR><BR>myCommand2=NEW SQLCommand("INSERT INTO ORDERED (sessionid, ordernumber, name, vcode, buyerid, proddesc, prodid, taghidden, price, qty, total) SELECT ORDERS.ordernumber, ORDERS.ordernumber,, ORDERS.vcode, ORDERS.buyerid, ORDERS.proddesc, ORDERS.prodid, ORDERS.tagnumber, (ORDERS.price - (ORDERS.price * "& request.querystring("disc")/100&")), ORDERS.qty, ( - ( * "& request.querystring("disc")/100&")) from ORDERS WHERE buyerid=&#039;"&request.querystring("bid")&"&#039; AND ordernumber=&#039;"&request.querystring("num")&"&# 039; AND vcode=&#039;"&request.querystring("vcode")&"&#039; ", myConnection)<BR>myCommand2.executereader()

  2. #2
    Join Date
    Dec 1969

    Default RE: Using Forwardslash to divide in SQL Query

    You basically have a syntax error.<BR>You need spaces in between the &#060;100&"&#062;. It should be &#060;100 & "&#062;. You have this in two places. <BR>For simplicity, you might want to declare your variables like so.<BR><BR>Dim sql as string<BR>Dim myCommand2 as SqlCommand<BR><BR>sql = "INSERT INTO ..."<BR>sql &= " SELECT ORDERS.ordernumber ..."<BR>sql &= " WHERE buyerid=&#039;" & request.querystring "<BR>myCommand2.CommandText = sql<BR><BR>Be sure to leave spaces when concatenating or else you will run into more syntax errors. ;-)<BR><BR>hth<BR><BR>matt

Posting Permissions

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