I have create a class called OrderInfo as follows:
I have a function called GetOrderDetails as follows:
I have a subprocedure called PopulateControls with the following code included:
I receive an error on the highlighted line.
"Value of type 'System.Data.SqlClient.SqlDataReader' cannot be converted to 'OrderInfo'.
This code worked fine in ASP.NET 1.1 ... but I receive the error in 2.0 ....
Any Suggestions?
VB.NET:
Public Class OrderInfo
Public OrderID As String
Public TotalAmount As Decimal
Public DateCreated As String
Public DateShipped As String
Public Verified As Boolean
Public Completed As Boolean
Public Canceled As Boolean
Public Comments As String
Public CustomerName As String
Public ShippingAddress As String
Public CustomerEmail As String
End Class
I have a function called GetOrderDetails as follows:
VB.NET:
Public Shared Function GetOrderDetails(ByVal orderId As String) As SqlDataReader
' create the connection object
Dim connection As New SqlConnection("connectionString")
' create and initialize command object
Dim command As New SqlCommand("GetOrderDetails", connection)
command.CommandType = CommandType.StoredProcedure
' add an input parameter and supply a value for it
command.Parameters.Add("@OrderID", SqlDbType.SmallInt)
command.Parameters("@OrderID").Value = orderId
' return the results
Try
' open the connection
connection.Open()
'return the SqlDataReader to the calling function
Return command.ExecuteReader(CommandBehavior.CloseConnection)
Catch ex As Exception
' close the connection and rethrow the exception
connection.Close()
Throw ex
End Try
End Function
VB.NET:
dim orderInfo as new OrderInfo
[highlight]orderInfo = OrderManager.GetOrderDetails(orderId)[/highlight]
"Value of type 'System.Data.SqlClient.SqlDataReader' cannot be converted to 'OrderInfo'.
This code worked fine in ASP.NET 1.1 ... but I receive the error in 2.0 ....
Any Suggestions?