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
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