I am creating a shopping website from codes given to me by a lecturer however in the code i have the following..
Sub Page_Load
if Not Page.IsPostBack then
myexample.DataSource=GetExample()
myexample.DataBind()
makeCart()
end if
End Sub
Function makeCart()
objDT = New System.Data.DataTable("Cart")
objDT.Columns.Add("Example1", GetType(Integer))
objDT.Columns.Add("example2", GetType(String))
objDT.Columns.Add("example3", GetType(String))
Session("Cart") = objDT
End Function
Im not aware of where this cart is made and where i can view it? or will it be on the same page?
Even when running my final code this appears...is it to do with the cart?
No value given for one or more required parameters.
Description: An unhandled exception occurred during the execution of the current web request. Please
review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.OleDb.OleDbException: No value given for one or more required parameters.
Function GetExample() As System.Data.DataSet
Dim connectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0; Ole DB Services=-4; Data Source=" & Server.MapPath("ExampleShop.mdb")
Dim dbConnection As System.Data.IDbConnection = New System.Data.OleDb.OleDbConnection(connectionString)
Dim queryString As String = "SELECT [Example_Name].[Example_Name], [Example_Price].[Example_Price], [Example_Type].[Example_Type] FROM [Products]"& _
""
Dim dbCommand As System.Data.IDbCommand = New System.Data.OleDb.OleDbCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection
Dim dataAdapter As System.Data.IDbDataAdapter = New System.Data.OleDb.OleDbDataAdapter
dataAdapter.SelectCommand = dbCommand
Dim dataSet As System.Data.DataSet = New System.Data.DataSet
dataAdapter.Fill(dataSet)
Dim queryString As String = "SELECT [Example_Name].[Example_Name], [Example_Price].[Example_Price], [Example_Type].[Example_Type] FROM [Products]"& _
""
Can you replace the above statement with this and try
Dim queryString As String = "SELECT [Example_Name], [Example_Price], [Example_Type] FROM [Products]"
razzied104
Dim connectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0; Ole DB Services=-4; Data Source=" & Server.MapPath("ExampleShop.mdb")
Could you put a break point and see the string in the connectionString variable is correct.
Thanks & Regards,
Bimal
Marked as answer by razzied104 on Mar 25, 2012 09:40 PM
Dim queryString As String = "SELECT [Example_Name].[Example_Name], [Example_Price].[Example_Price], [Example_Type].[Example_Type] FROM [Products]"& _
""
Can you replace the above statement with this and try
Dim queryString As String = "SELECT [Example_Name], [Example_Price], [Example_Type] FROM [Products]"
Thanks but its working now, your a life saver, that change was correct. Thanks Bimal!!
razzied104
Member
9 Points
7 Posts
What is the CommandName refering to?
Mar 25, 2012 08:02 PM|LINK
I am creating a shopping website from codes given to me by a lecturer however in the code i have the following..
Sub Page_Load
if Not Page.IsPostBack then
myexample.DataSource=GetExample()
myexample.DataBind()
makeCart()
end if
End Sub
Function makeCart()
objDT = New System.Data.DataTable("Cart")
objDT.Columns.Add("Example1", GetType(Integer))
objDT.Columns.Add("example2", GetType(String))
objDT.Columns.Add("example3", GetType(String))
Session("Cart") = objDT
End Function
Im not aware of where this cart is made and where i can view it? or will it be on the same page?
Even when running my final code this appears...is it to do with the cart?
No value given for one or more required parameters.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.OleDb.OleDbException: No value given for one or more required parameters.
Stack Trace:
Thanks for any help!!
Bimalvv
Contributor
2356 Points
478 Posts
Re: What is the CommandName refering to?
Mar 25, 2012 08:36 PM|LINK
It is because of you Db communication. Could you please share the code of GetExample() method?
Bimal
razzied104
Member
9 Points
7 Posts
Re: What is the CommandName refering to?
Mar 25, 2012 08:42 PM|LINK
Is this what you need?
Function GetExample() As System.Data.DataSet
Dim connectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0; Ole DB Services=-4; Data Source=" & Server.MapPath("ExampleShop.mdb")
Dim dbConnection As System.Data.IDbConnection = New System.Data.OleDb.OleDbConnection(connectionString)
Dim queryString As String = "SELECT [Example_Name].[Example_Name], [Example_Price].[Example_Price], [Example_Type].[Example_Type] FROM [Products]"& _
""
Dim dbCommand As System.Data.IDbCommand = New System.Data.OleDb.OleDbCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection
Dim dataAdapter As System.Data.IDbDataAdapter = New System.Data.OleDb.OleDbDataAdapter
dataAdapter.SelectCommand = dbCommand
Dim dataSet As System.Data.DataSet = New System.Data.DataSet
dataAdapter.Fill(dataSet)
Return dataSet
End Function
Bimalvv
Contributor
2356 Points
478 Posts
Re: What is the CommandName refering to?
Mar 25, 2012 09:03 PM|LINK
Can you replace the above statement with this and try
Could you put a break point and see the string in the connectionString variable is correct.
Bimal
razzied104
Member
9 Points
7 Posts
Re: What is the CommandName refering to?
Mar 25, 2012 09:09 PM|LINK
Sorry i didnt quite understand the last bit haha im still new to this. What do u mean? Thanks
Bimalvv
Contributor
2356 Points
478 Posts
Re: What is the CommandName refering to?
Mar 25, 2012 09:38 PM|LINK
Checkout this http://msdn.microsoft.com/en-us/library/ktf38f66(v=vs.71).aspx
Bimal
razzied104
Member
9 Points
7 Posts
Re: What is the CommandName refering to?
Mar 25, 2012 09:40 PM|LINK
Thanks but its working now, your a life saver, that change was correct. Thanks Bimal!!