HI
I have changed everything to ISBN, both in the database and in .NET, nothing should say ModelNumber. the application only falls over when I click on a product for more detail, thats when I get the error msg. It is fine if I click on add to cart from the product lists, it includes the ISBN details in the cart.
As I understand it for product details there is the aspx page and the .VB page. the error msg is stating 'ISBN' is not a member of 'IBuySpy.ProductDetails', but as far as I can see it is. the code for the .VB file is shown below.
Im quite new to using ASP.NET & I get a bit frustrated when I cannot see what the problem is, thanks for your help.
Imports System
Imports System.Configuration
Imports System.Data
Imports System.Data.SqlClient
Namespace IBuySpy
'*******************************************************
'
' ProductDetails Class
'
' A simple data class that encapsulates details about
' a particular product inside the IBuySpy Product
' database.
'
'*******************************************************
Public Class ProductDetails
Public ISBN As String
Public ModelName As String
Public ProductImage As String
Public UnitCost As Decimal
Public Description As String
End Class
'*******************************************************
'
' ProductsDB Class
'
' Business/Data Logic Class that encapsulates all data
' logic necessary to query products within
' the IBuySpy Products database.
'
'*******************************************************
Public Class ProductsDB
'*******************************************************
'
' ProductsDB.GetProductCategories() Method <a name="GetProductCategories"></a>
'
' The GetProductCategories method returns a DataReader that exposes all
' product categories (and their CategoryIDs) within the IBuySpy Products
' database. The SQLDataReaderResult struct also returns the
' SQL connection, which must be explicitly closed after the
' data from the DataReader is bound into the controls.
'
' Other relevant sources:
' + ProductCategoryList Stored Procedure
'
'*******************************************************
Public Function GetProductCategories() As SqlDataReader
' Create Instance of Connection and Command Object
Dim myConnection As SqlConnection = New SqlConnection(ConfigurationSettings.AppSettings("ConnectionString"))
Dim myCommand As SqlCommand = New SqlCommand("ProductCategoryList", myConnection)
' Mark the Command as a SPROC
myCommand.CommandType = CommandType.StoredProcedure
' Execute the command
myConnection.Open()
Dim result As SqlDataReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection)
' Return the datareader result
Return result
End Function
'*******************************************************
'
' ProductsDB.GetProducts() Method <a name="GetProducts"></a>
'
' The GetProducts method returns a struct containing a forward-only,
' read-only DataReader. This displays all products within a specified
' product category. The SQLDataReaderResult struct also returns the
' SQL connection, which must be explicitly closed after the
' data from the DataReader is bound into the controls.
'
' Other relevant sources:
' + ProductsByCategory Stored Procedure
'
'*******************************************************
Public Function GetProducts(ByVal categoryID As Integer) As SqlDataReader
' Create Instance of Connection and Command Object
Dim myConnection As SqlConnection = New SqlConnection(ConfigurationSettings.AppSettings("ConnectionString"))
Dim myCommand As SqlCommand = New SqlCommand("ProductsByCategory", myConnection)
' Mark the Command as a SPROC
myCommand.CommandType = CommandType.StoredProcedure
' Add Parameters to SPROC
Dim parameterCategoryID As SqlParameter = New SqlParameter("@CategoryID", SqlDbType.Int, 4)
parameterCategoryID.Value = categoryID
myCommand.Parameters.Add(parameterCategoryID)
' Execute the command
myConnection.Open()
Dim result As SqlDataReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection)
' Return the datareader result
Return result
End Function
'*******************************************************
'
' ProductsDB.GetProductDetails() Method <a name="GetProductDetails"></a>
'
' The GetProductDetails method returns a ProductDetails
' struct containing specific details about a specified
' product within the IBuySpy Products Database.
'
' Other relevant sources:
' + ProductDetail Stored Procedure
'
'*******************************************************
Public Function GetProductDetails(ByVal productID As Integer) As ProductDetails
' Create Instance of Connection and Command Object
Dim myConnection As SqlConnection = New SqlConnection(ConfigurationSettings.AppSettings("ConnectionString"))
Dim myCommand As SqlCommand = New SqlCommand("ProductDetail", myConnection)
' Mark the Command as a SPROC
myCommand.CommandType = CommandType.StoredProcedure
' Add Parameters to SPROC
Dim parameterProductID As SqlParameter = New SqlParameter("@ProductID", SqlDbType.Int, 4)
parameterProductID.Value = productID
myCommand.Parameters.Add(parameterProductID)
Dim parameterUnitCost As SqlParameter = New SqlParameter("@UnitCost", SqlDbType.Money, 8)
parameterUnitCost.Direction = ParameterDirection.Output
myCommand.Parameters.Add(parameterUnitCost)
Dim parameterISBN As SqlParameter = New SqlParameter("@ISBN", SqlDbType.NVarChar, 50)
parameterISBN.Direction = ParameterDirection.Output
myCommand.Parameters.Add(parameterISBN)
Dim parameterModelName As SqlParameter = New SqlParameter("@ModelName", SqlDbType.NVarChar, 50)
parameterModelName.Direction = ParameterDirection.Output
myCommand.Parameters.Add(parameterModelName)
Dim parameterProductImage As SqlParameter = New SqlParameter("@ProductImage", SqlDbType.NVarChar, 50)
parameterProductImage.Direction = ParameterDirection.Output
myCommand.Parameters.Add(parameterProductImage)
Dim parameterDescription As SqlParameter = New SqlParameter("@Description", SqlDbType.NVarChar, 3800)
parameterDescription.Direction = ParameterDirection.Output
myCommand.Parameters.Add(parameterDescription)
' Open the connection and execute the Command
myConnection.Open()
myCommand.ExecuteNonQuery()
myConnection.Close()
' Create and Populate ProductDetails Struct using
' Output Params from the SPROC
Dim myProductDetails As ProductDetails = New ProductDetails()
myProductDetails.ModelName = CStr(parameterModelName.Value)
myProductDetails.ProductImage = CStr(parameterProductImage.Value).Trim()
myProductDetails.UnitCost = CType(parameterUnitCost.Value, Decimal)
myProductDetails.Description = CStr(parameterDescription.Value).Trim()
myProductDetails.ISBN = CStr(parameterISBN.Value)
Return myProductDetails
End Function