jackwebb22002
asked on
Problem Using Stored Procedures
I'm having a problem using a stored procedure when trying to get all rows of a table.
I have a property (see code snippet) named "AllRows" which returns a strongly typed DataTable table of all rows in a SQL mdf DB.
When I execute, an Exception is caught and the message says that:
LastError "Unable to cast object of type 'System.Data.DataTable' to type 'DestinationDataTable'."
Stored procedure is also attached in code snippet.
Thanks, and Any help on this topic would be most appreciated.
JJW
I have a property (see code snippet) named "AllRows" which returns a strongly typed DataTable table of all rows in a SQL mdf DB.
When I execute, an Exception is caught and the message says that:
LastError "Unable to cast object of type 'System.Data.DataTable' to type 'DestinationDataTable'."
Stored procedure is also attached in code snippet.
Thanks, and Any help on this topic would be most appreciated.
JJW
''' <summary>
''' All rows in a data table
''' </summary>
''' <value></value>
''' <returns></returns>
''' <remarks></remarks>
Public Shared ReadOnly Property AllRows() As TravelDataSet.DestinationDataTable
Get
Try
Return DirectCast(Utils.GetTable("spAllDestinations", CommandType.StoredProcedure), TravelDataSet.DestinationDataTable)
Catch ex As Exception
LastError = ex.Message
Return Nothing
End Try
End Get
End Property
''' <summary>
''' All rows in a data table
''' </summary>
''' <value></value>
''' <returns></returns>
''' <remarks></remarks>
Public Shared ReadOnly Property AllRows() As TravelDataSet.DestinationDataTable
Get
Try
Return DirectCast(Utils.GetTable("spAllDestinations", CommandType.StoredProcedure), TravelDataSet.DestinationDataTable)
Catch ex As Exception
LastError = ex.Message
Return Nothing
End Try
End Get
End Property
Stored Procedure:
ALTER PROCEDURE dbo.spAllDestinations
AS
SET NOCOUNT ON;
SELECT DestinationId,
Destination,
Address,
City,
State,
Zip,
PhoneNumber,
DailyCost,
DepositPctRequired,
RoomCapacity
FROM [Destination]
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Now I know I can proceed, with all SP's for other functions, and use the Getdata to retrieve an entire table.