records returned from datareader error

D

Davef

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 address 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 address removed)
______________________
 
R

ravi sankar

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,710
Latest member
bernietqt

Latest Threads

Top