Extracting data from a DataSet

G

Guest

Hello,

I am using the following code to pull data from my dataset in Page_Load

Dim str As String
Dim ds As System.Data.DataSet
Dim dt As System.Data.DataTable
Dim dr As System.Data.DataRow
Dim dc As System.Data.DataColumn

ds = UserTypeQueryMethod()

For Each dt In ds.Tables
For Each dr In dt.Rows
For Each dc In dt.Columns
if dr(dc) = "owner" then
if dc.DefaultValue = "bob" then
msgbox("good")
exit sub
end if
end if
Next dc
Next dr
Next dt

The code gets in to the "owner" field with no problem but I get an exception
that states:

System.InvalidCastException: Operator is not valid for type 'DBNull' and
string "bob"

How do I use the dc.DataType property to check that I have a string ??

thanks for any replies
 

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

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,818
Messages
2,569,727
Members
45,664
Latest member
Phil79581

Latest Threads

Top