SQL Sum + var

Results 1 to 3 of 3

Thread: SQL Sum + var

  1. #1
    Eiki Guest

    Default SQL Sum + var

    Ok...this is my first question. I&#039;m pretty much beginner in this.<BR><BR>I sum a field from the database with an SQL statement and put it into a variable. Now I need to add it again with another variable passed from a form and I got error message "Type Mismatch"<BR><BR>Here is the code that I have:<BR>sumSQL = "SELECT SUM(gTotal) FROM table " &_<BR>"WHERE contract = &#039;" & request("contract") & "&#039; "<BR><BR>set total = oConn.Execute(sumSQL)<BR>trackfee = total + trackfee <BR><BR>TIA for any help!

  2. #2
    Join Date
    Dec 1969
    Los Angeles, CA

    Default RE: SQL Sum + var

    seu cint or clng or whatever<BR><BR><BR>you have to convert BOTH the values to a number ot add the values.<BR><BR>

  3. #3
    Rob Guest

    Default RE: SQL Sum + var

    You have to declare the data typw. VBScript uses a variant data type menaing anything can be anything until you tell it it is something.<BR><BR>myVar = CLng(rs("mySum"))<BR><BR>or if it is going to be decimal<BR><BR>myVar = CDbl(rs("mySum"))<BR><BR>Then you can add.<BR><BR>Rob

Posting Permissions

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