bobleny
04-03-2011, 08:13 PM
I have the following program:
Dim SetData As DataSet ' Stores the information
Dim Connection As New OleDb.OleDbConnection
Dim Adapter As OleDb.OleDbDataAdapter
' Connect to the database
Connection.ConnectionString = "PROVIDER = Microsoft.Jet.OLEDB.4.0; Data Source = ./App_Data/VB.mdb"
Connection.Open() ' Open the database
' Get the information from the database
Adapter = New OleDb.OleDbDataAdapter("SELECT * FROM [Customer Query] WHERE [Name] = [George]", Connection)
SetData = New DataSet
Adapter.Fill(SetData, "Query") ' Store the database information in DataSet
Connection.Close() ' Close the connection
The problem appears to be with the where clause of the SQL query. When I remove the where clause, the program works fine. However, with the where clause I get this error:
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.
Source Error:
Line 43: Adapter = New OleDb.OleDbDataAdapter("SELECT * FROM [Customer Query] WHERE [Name] = [George]", Connection)
Line 44: SetData = New DataSet
Line 45: Adapter.Fill(SetData, "Query") ' Store the database information in DataSet
Line 46: Connection.Close() ' Close the connection
Line 47:
Source File: C:\Documents and Settings\Bob\Desktop\DatabaseRecords\Default.aspx Line: 45
Stack Trace:
[OleDbException (0x80040e10): No value given for one or more required parameters.]
System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(OleDbHResult hr) +1003520
System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult) +255
System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult) +188
System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult) +58
System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method) +161
System.Data.OleDb.OleDbCommand.ExecuteReader(CommandBehavior behavior) +116
System.Data.OleDb.OleDbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior) +4
System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +130
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +287
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable) +92
ASP.default_aspx.Selection_Change() in C:\Documents and Settings\Bob\Desktop\DatabaseRecords\Default.aspx:45
ASP.default_aspx._Lambda$__2(Object a0, EventArgs a1) in C:\Documents and Settings\Bob\Desktop\DatabaseRecords\Default.aspx:89
System.Web.UI.WebControls.ListControl.OnSelectedIndexChanged(EventArgs e) +111
System.Web.UI.WebControls.DropDownList.RaisePostDataChangedEvent() +134
System.Web.UI.WebControls.DropDownList.System.Web.UI.IPostBackDataHandler.RaisePostDataChangedEvent( ) +10
System.Web.UI.Page.RaiseChangedEvents() +165
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1485
When I use the where clause in a standard VB.NET windows application I have no problem, so I don't know what to do.
Any ideas?
Thanks!
Dim SetData As DataSet ' Stores the information
Dim Connection As New OleDb.OleDbConnection
Dim Adapter As OleDb.OleDbDataAdapter
' Connect to the database
Connection.ConnectionString = "PROVIDER = Microsoft.Jet.OLEDB.4.0; Data Source = ./App_Data/VB.mdb"
Connection.Open() ' Open the database
' Get the information from the database
Adapter = New OleDb.OleDbDataAdapter("SELECT * FROM [Customer Query] WHERE [Name] = [George]", Connection)
SetData = New DataSet
Adapter.Fill(SetData, "Query") ' Store the database information in DataSet
Connection.Close() ' Close the connection
The problem appears to be with the where clause of the SQL query. When I remove the where clause, the program works fine. However, with the where clause I get this error:
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.
Source Error:
Line 43: Adapter = New OleDb.OleDbDataAdapter("SELECT * FROM [Customer Query] WHERE [Name] = [George]", Connection)
Line 44: SetData = New DataSet
Line 45: Adapter.Fill(SetData, "Query") ' Store the database information in DataSet
Line 46: Connection.Close() ' Close the connection
Line 47:
Source File: C:\Documents and Settings\Bob\Desktop\DatabaseRecords\Default.aspx Line: 45
Stack Trace:
[OleDbException (0x80040e10): No value given for one or more required parameters.]
System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(OleDbHResult hr) +1003520
System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult) +255
System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult) +188
System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult) +58
System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method) +161
System.Data.OleDb.OleDbCommand.ExecuteReader(CommandBehavior behavior) +116
System.Data.OleDb.OleDbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior) +4
System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +130
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +287
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable) +92
ASP.default_aspx.Selection_Change() in C:\Documents and Settings\Bob\Desktop\DatabaseRecords\Default.aspx:45
ASP.default_aspx._Lambda$__2(Object a0, EventArgs a1) in C:\Documents and Settings\Bob\Desktop\DatabaseRecords\Default.aspx:89
System.Web.UI.WebControls.ListControl.OnSelectedIndexChanged(EventArgs e) +111
System.Web.UI.WebControls.DropDownList.RaisePostDataChangedEvent() +134
System.Web.UI.WebControls.DropDownList.System.Web.UI.IPostBackDataHandler.RaisePostDataChangedEvent( ) +10
System.Web.UI.Page.RaiseChangedEvents() +165
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1485
When I use the where clause in a standard VB.NET windows application I have no problem, so I don't know what to do.
Any ideas?
Thanks!