PC Review


Reply
Thread Tools Rate Thread

records returned from datareader error

 
 
Davef
Guest
Posts: n/a
 
      28th Aug 2003

I get an error at: If IsDBNull(dr2("tax")) Then
if there are no records returned. How can I deal with that?


Dim dr2 As SqlDataReader = Salestax.GetMachSalesTax(SalesCookieID)
dr2.Read()
If IsDBNull(dr2("tax")) Then
taxPercent.Value = "0"
Else
taxPercent.Value = dr2("tax")
End If

Dim dr As SqlDataReader =
myCommand.ExecuteReader(CommandBehavior.CloseConnection)

' Return the datareader

Return dr


--

______________________
David Fetrow
HelixPoint LLC.
http://www.helixpoint.com
(E-Mail Removed)

Interested in Affordable Email Marketing?
Check out the HelixMailer at http://www.helixpoint.com/helixmailer.asp
If you are interested in becoming a Reseller of HelixPoint products, contact
(E-Mail Removed)
______________________


 
Reply With Quote
 
 
 
 
ravi sankar
Guest
Posts: n/a
 
      28th Aug 2003
Your code should be something like this

Dim dr2 As SqlDataReader = Salestax.GetMachSalesTax
(SalesCookieID)
if dr2.Read() then
If IsDBNull(dr2("tax")) Then
taxPercent.Value = "0"
Else
taxPercent.Value = dr2("tax")
End If
Else
' No records found
End if


' Return the datareader




>-----Original Message-----
>
>I get an error at: If IsDBNull(dr2("tax")) Then
>if there are no records returned. How can I deal with

that?
>
>
>Dim dr2 As SqlDataReader = Salestax.GetMachSalesTax

(SalesCookieID)
>dr2.Read()
>If IsDBNull(dr2("tax")) Then
>taxPercent.Value = "0"
>Else
>taxPercent.Value = dr2("tax")
>End If
>
>Dim dr As SqlDataReader =
>myCommand.ExecuteReader(CommandBehavior.CloseConnection)
>
>' Return the datareader
>
>Return dr
>
>
>--
>
>______________________
>David Fetrow
>HelixPoint LLC.
>http://www.helixpoint.com
>(E-Mail Removed)
>
>Interested in Affordable Email Marketing?
>Check out the HelixMailer at

http://www.helixpoint.com/helixmailer.asp
>If you are interested in becoming a Reseller of

HelixPoint products, contact
>(E-Mail Removed)
>______________________
>
>
>.
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
DataReader Limits data returned! TY Microsoft ADO .NET 3 16th May 2012 01:59 AM
How to process datareader nulls coming from datareader? JB Microsoft C# .NET 4 3rd Nov 2008 01:56 AM
Checking for datareader returned types at runtime =?Utf-8?B?Sm/Do28gQ29zdGE=?= Microsoft C# .NET 2 24th Mar 2006 03:47 PM
Should I close a datareader returned using daab? hansiman Microsoft ASP .NET 7 11th May 2005 01:02 PM
DataReader and Returned Parms Jim Heavey Microsoft ADO .NET 3 19th Dec 2003 09:39 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:19 AM.