Recordset Empty Error

Discussion in 'ASP General' started by J P Singh, Jan 16, 2004.

  1. J P Singh

    J P Singh Guest

    Hi All

    Does anyone know why the code below gives me an error on the line
    strTt = FormatNumber( RS("Expr1") , 2)

    whenever RS is empty.

    Am I doing something wrong?

    <%
    SQL = " SELECT Sum(PODetails.Amount) AS Expr1 FROM PODetails where PONumber=
    " & rstDBEdit.Fields("PONumber").Value

    Set RS = Server.CreateObject("ADODB.Recordset")
    RS.Open SQL, CONN_STRING

    if not rs.eof then
    strTt = FormatNumber( RS("Expr1") , 2)
    else
    strTT= 0.00
    strTT = FormatNumber( strTT , 2)
    end if
    Response.write strTT

    %>
     
    J P Singh, Jan 16, 2004
    #1
    1. Advertising

  2. J P Singh

    Alex Goodey Guest

    whats the error?


    "J P Singh" <noemail@asIhatespam> wrote in message
    news:...
    > Hi All
    >
    > Does anyone know why the code below gives me an error on the line
    > strTt = FormatNumber( RS("Expr1") , 2)
    >
    > whenever RS is empty.
    >
    > Am I doing something wrong?
    >
    > <%
    > SQL = " SELECT Sum(PODetails.Amount) AS Expr1 FROM PODetails where

    PONumber=
    > " & rstDBEdit.Fields("PONumber").Value
    >
    > Set RS = Server.CreateObject("ADODB.Recordset")
    > RS.Open SQL, CONN_STRING
    >
    > if not rs.eof then
    > strTt = FormatNumber( RS("Expr1") , 2)
    > else
    > strTT= 0.00
    > strTT = FormatNumber( strTT , 2)
    > end if
    > Response.write strTT
    >
    > %>
    >
    >
     
    Alex Goodey, Jan 16, 2004
    #2
    1. Advertising

  3. J P Singh

    J P Singh Guest

    Hi Alex

    Microsoft VBScript runtime error '800a000d'
    Type mismatch: 'FormatNumber'

    /request1.asp, line 727





    "Alex Goodey" <> wrote in message
    news:bu8s5q$epa68$-berlin.de...
    > whats the error?
    >
    >
    > "J P Singh" <noemail@asIhatespam> wrote in message
    > news:...
    > > Hi All
    > >
    > > Does anyone know why the code below gives me an error on the line
    > > strTt = FormatNumber( RS("Expr1") , 2)
    > >
    > > whenever RS is empty.
    > >
    > > Am I doing something wrong?
    > >
    > > <%
    > > SQL = " SELECT Sum(PODetails.Amount) AS Expr1 FROM PODetails where

    > PONumber=
    > > " & rstDBEdit.Fields("PONumber").Value
    > >
    > > Set RS = Server.CreateObject("ADODB.Recordset")
    > > RS.Open SQL, CONN_STRING
    > >
    > > if not rs.eof then
    > > strTt = FormatNumber( RS("Expr1") , 2)
    > > else
    > > strTT= 0.00
    > > strTT = FormatNumber( strTT , 2)
    > > end if
    > > Response.write strTT
    > >
    > > %>
    > >
    > >

    >
    >
     
    J P Singh, Jan 16, 2004
    #3
  4. J P Singh

    TomB Guest

    Because if it's empty, it can't format it to a number.

    Dim theVal
    theVal=RS.Fields("Expr1").Value 'may want to change Expr1 to something a
    little more helpful
    if isNumeric(theVal) then
    strTt=FormatNumber(theVal,2)
    else
    strTt="0.00" 'or whatever else the default should be.
    end if


    There's an FAQ at www.aspfaq.com about the isNumeric function - which you
    may wish to review.


    "J P Singh" <noemail@asIhatespam> wrote in message
    news:...
    > Hi All
    >
    > Does anyone know why the code below gives me an error on the line
    > strTt = FormatNumber( RS("Expr1") , 2)
    >
    > whenever RS is empty.
    >
    > Am I doing something wrong?
    >
    > <%
    > SQL = " SELECT Sum(PODetails.Amount) AS Expr1 FROM PODetails where

    PONumber=
    > " & rstDBEdit.Fields("PONumber").Value
    >
    > Set RS = Server.CreateObject("ADODB.Recordset")
    > RS.Open SQL, CONN_STRING
    >
    > if not rs.eof then
    > strTt = FormatNumber( RS("Expr1") , 2)
    > else
    > strTT= 0.00
    > strTT = FormatNumber( strTT , 2)
    > end if
    > Response.write strTT
    >
    > %>
    >
    >
     
    TomB, Jan 16, 2004
    #4
  5. J P Singh

    J P Singh Guest

    Top Man

    Works like a charm


    "TomB" <> wrote in message
    news:...
    > Because if it's empty, it can't format it to a number.
    >
    > Dim theVal
    > theVal=RS.Fields("Expr1").Value 'may want to change Expr1 to something a
    > little more helpful
    > if isNumeric(theVal) then
    > strTt=FormatNumber(theVal,2)
    > else
    > strTt="0.00" 'or whatever else the default should be.
    > end if
    >
    >
    > There's an FAQ at www.aspfaq.com about the isNumeric function - which you
    > may wish to review.
    >
    >
    > "J P Singh" <noemail@asIhatespam> wrote in message
    > news:...
    > > Hi All
    > >
    > > Does anyone know why the code below gives me an error on the line
    > > strTt = FormatNumber( RS("Expr1") , 2)
    > >
    > > whenever RS is empty.
    > >
    > > Am I doing something wrong?
    > >
    > > <%
    > > SQL = " SELECT Sum(PODetails.Amount) AS Expr1 FROM PODetails where

    > PONumber=
    > > " & rstDBEdit.Fields("PONumber").Value
    > >
    > > Set RS = Server.CreateObject("ADODB.Recordset")
    > > RS.Open SQL, CONN_STRING
    > >
    > > if not rs.eof then
    > > strTt = FormatNumber( RS("Expr1") , 2)
    > > else
    > > strTT= 0.00
    > > strTT = FormatNumber( strTT , 2)
    > > end if
    > > Response.write strTT
    > >
    > > %>
    > >
    > >

    >
    >
     
    J P Singh, Jan 16, 2004
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. John

    empty/non-empty element

    John, Jul 15, 2003, in forum: XML
    Replies:
    1
    Views:
    1,033
    Klaus Johannes Rusch
    Jul 16, 2003
  2. RufusGoofus

    binding empty recordset to datagrid

    RufusGoofus, Jan 22, 2005, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    109
    RufusGoofus
    Jan 22, 2005
  3. Hung Huynh
    Replies:
    8
    Views:
    308
    Bob Barrows
    Sep 24, 2003
  4. Bruce Duncan

    Empty Recordset???

    Bruce Duncan, Feb 3, 2004, in forum: ASP General
    Replies:
    5
    Views:
    142
  5. Eli Sidwell

    Returning RecordSet to ASP is empty

    Eli Sidwell, Feb 10, 2004, in forum: ASP General
    Replies:
    4
    Views:
    214
    Eli Sidwell
    Feb 11, 2004
Loading...

Share This Page