|
-
Feb 6th, 2003, 01:30 PM
#1
Thread Starter
Lively Member
Specified cast is not valid. Error
Hi,
I have an data set that I retrieve corectly from a table(dealers).
Then I try to cast this dataset to as type delaserfl that is defined in an xsd file ( I obtained that file by drag and drop the table from sql to DealerFl.xsd file)
All this is done into this function
************************************
Public Function GetDealerInfo(ByVal dlr As String, ByVal connectionString As String) As DealerFl
Dim strSQL As String
Dim conn As Data.SqlClient.SqlConnection = New Data.SqlClient.SqlConnection(connectionString)
conn.Open()
strSQL = " SELECT * "
strSQL &= " FROM dealer.dbo.DealerFlags d "
strSQL &= " WHERE dlrAct = " & dlr.ToString
' Call ExecuteXmlReader static method of SqlHelper class that returns an XmlReader
' We pass in an open database connection object, command type, and command text
Dim ds As New DataSet()
Dim dfl As New DealerFl()
ds = SqlHelper.ExecuteDataset(conn, CommandType.Text, strSQL)
' I get the error at the next instruction
dfl = CType(ds, DealerFl)
Return dfl
End Function
****************************************
What may be wrong?
Thank you,
svatasoiu
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|