I'm expiencing a problem when using an access database with ASP.Net V1.1 and VB.
Im using the below code;
Dim searchName as String = " "
Dim searchSurname as String = " "
Dim searchGenre as String = " "
Dim searchISBN as String = " "
Dim searchTitle as String = " "
Sub Page_Load (Sender As Object, E As EventArgs)
End Sub
Sub PopulateDataGrid()
DataGrid1.Datasource = Books()
DataGrid1.DataBind()
End Sub
Function Books() As System.Data.DataSet
Dim connectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0; Ole DB Services=-4; Data Source=C:\Library\Book"& _
"s.mdb"
Dim dbConnection As System.Data.IDbConnection = New System.Data.OleDb.OleDbConnection(connectionString)
Dim queryString As String = "SELECT Authors.[Author First Name], Authors.[Author Last Name], Books.[ISBN Number],"& _
" Books.[Book Title], Books.[Author ID], Books.[Book Genre], Books.[Printer], Books.[Year Of Print], Books.[Book Description],"& _
" Books.[Current Stock]FROM Authors INNER JOIN Books ON Authors.[Author ID] = Books.[Author ID] WHERE (((Books.[Book Genre]) LIKE searchGenre ))"& _
" OR (((Books.[Book Title]) LIKE searchTitle )) OR (((Authors.[Author First Name]) LIKE searchName )) OR (((Authors.[Author Last Name]) "& _
"LIKE searchSurname )) OR (((Books.[ISBN Number]) LIKE searchISBN ));"
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
Sub DataGrid1_SelectedIndexChanged(sender As Object, e As EventArgs)
End Sub
Sub Button1_Click(sender As Object, e As EventArgs)
searchGenre = "*" + GENRE_SE.text
searchTitle = "*" + TITLE_SE.text
searchName = "*" + NAME_SE.text
searchSurname = "*" + SURNAME_SE.text
searchISBN = "*" + ISBN_SE.text
PopulateDataGrid()
End Sub
the SQL statement works in Access and the link works ok when you remove the where clause. the error constantly says:
Server Error in '/' Application.
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 39: dataAdapter.SelectCommand = dbCommand
Line 40: Dim dataSet As System.Data.DataSet = New System.Data.DataSet
Line 41: dataAdapter.Fill(dataSet)
Line 42:
Line 43: Return dataSet
Source File: C:\Library\Search.aspx Line: 41
Stack Trace:
[OleDbException (0x80040e10): No value given for one or more required parameters.]
System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(Int32 hr) +41
System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult) +122
System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult) +92
System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult) +65
System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method) +112
System.Data.OleDb.OleDbCommand.ExecuteReader(CommandBehavior behavior) +69
System.Data.OleDb.OleDbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior) +5
System.Data.Common.DbDataAdapter.FillFromCommand(Object data, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +304
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +77
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet) +38
ASP.Search_aspx.Books() in C:\Library\Search.aspx:41
ASP.Search_aspx.PopulateDataGrid() in C:\Library\Search.aspx:17
ASP.Search_aspx.Button1_Click(Object sender, EventArgs e) in C:\Library\Search.aspx:63
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +83
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain() +1277
Version Information: Microsoft .NET Framework Version:1.1.4322.573; ASP.NET Version:1.1.4322.573
jont
Member
10 Points
4 Posts
Help... "No value given for one or more required parameters."
Apr 25, 2007 10:54 PM|LINK
Hello,
I'm expiencing a problem when using an access database with ASP.Net V1.1 and VB.
Im using the below code;
Dim searchName as String = " "
Dim searchSurname as String = " "
Dim searchGenre as String = " "
Dim searchISBN as String = " "
Dim searchTitle as String = " "
Sub Page_Load (Sender As Object, E As EventArgs)
End Sub
Sub PopulateDataGrid()
DataGrid1.Datasource = Books()
DataGrid1.DataBind()
End Sub
Function Books() As System.Data.DataSet
Dim connectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0; Ole DB Services=-4; Data Source=C:\Library\Book"& _
"s.mdb"
Dim dbConnection As System.Data.IDbConnection = New System.Data.OleDb.OleDbConnection(connectionString)
Dim queryString As String = "SELECT Authors.[Author First Name], Authors.[Author Last Name], Books.[ISBN Number],"& _
" Books.[Book Title], Books.[Author ID], Books.[Book Genre], Books.[Printer], Books.[Year Of Print], Books.[Book Description],"& _
" Books.[Current Stock]FROM Authors INNER JOIN Books ON Authors.[Author ID] = Books.[Author ID] WHERE (((Books.[Book Genre]) LIKE searchGenre ))"& _
" OR (((Books.[Book Title]) LIKE searchTitle )) OR (((Authors.[Author First Name]) LIKE searchName )) OR (((Authors.[Author Last Name]) "& _
"LIKE searchSurname )) OR (((Books.[ISBN Number]) LIKE searchISBN ));"
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
Sub DataGrid1_SelectedIndexChanged(sender As Object, e As EventArgs)
End Sub
Sub Button1_Click(sender As Object, e As EventArgs)
searchGenre = "*" + GENRE_SE.text
searchTitle = "*" + TITLE_SE.text
searchName = "*" + NAME_SE.text
searchSurname = "*" + SURNAME_SE.text
searchISBN = "*" + ISBN_SE.text
PopulateDataGrid()
End Sub
the SQL statement works in Access and the link works ok when you remove the where clause. the error constantly says:
Server Error in '/' Application.
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:
Source File: C:\Library\Search.aspx Line: 41
Stack Trace:
Version Information: Microsoft .NET Framework Version:1.1.4322.573; ASP.NET Version:1.1.4322.573
I would really apreciate any help.
Many Thanks Jon.
smiling4ever
All-Star
15825 Points
3123 Posts
Re: Help... "No value given for one or more required parameters."
Apr 25, 2007 11:24 PM|LINK
ahsan
Member
294 Points
82 Posts
Re: Help... "No value given for one or more required parameters."
Apr 26, 2007 09:08 PM|LINK
numeric variable must contain 0 if no value assigned, may be this issue.
What you can do print you SQL statement and try to execute that SQL in access query, you can easily find the problem :)
Happy coding
Tribal DDB
Chicago IL
jont
Member
10 Points
4 Posts
Re: Help... "No value given for one or more required parameters."
Apr 29, 2007 04:32 PM|LINK
Hello, thank you for your replies...
I have sorted it! The query was correct, however, the query was not looking inside the value... to get around this you have to create a new attribute:
Dim dbParam_userID As System.Data.IDataParameter = New System.Data.OleDb.OleDbParameter
dbParam_userID.ParameterName = "@GENRESE"
dbParam_userID.Value = GENRESE
dbParam_userID.DbType = System.Data.DbType.String
dbCommand.Parameters.Add(dbParam_userID)
and then refer to the name of the attribute, i.e. in this case @GENRESE.
Again thanks for your replies.
Jon
[:D]
ahsan
Member
294 Points
82 Posts
Re: Help... "No value given for one or more required parameters."
Apr 29, 2007 04:43 PM|LINK
ohh IC :)
GOod luck with your further codding ....
Tribal DDB
Chicago IL