Checking for datareader returned types at runtime

G

Guest

dr is a dataset, str1 is a string. How can I know the type inside the
datareader field?
I tried:

if(dr.GetValue(n) is System.Int32)
str1=Convert.ToString(dr.GetSqlInt32(n))
else
str1=dr.GetString(n)

But the compiler warns the if is always false.
Thanks in advance
 

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

Top