Click here to Skip to main content
15,888,089 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Why this error is giving

Error - System.Data.OleDb.OleDbException: No value given for one or more required parameters.


my code is given below


HTML
<html>
<head  runat="server">
    <title>Save Images In Folder and Display Images in Gridview from folder</title>
 <style type="text/css">
.normal
{
background-color:white;
}
.highlight
{
background-color:Blue;
}
</style>
</head>
<body>
    <form id="form1"  runat="server">
    <div>
    <asp:FileUpload ID="fileuploadimages" runat="server" />
    <br />
    <asp:Button ID="btnSubmit" runat="server" Text="Submit"/>
    </div>
    <div>
    <asp:GridView runat="server" ID="gvImages" AutoGenerateColumns="false" AllowPaging="True" DataSourceID="AccessDataSource1" CssClass="Gridview" HeaderStyle-BackColor="#61A6F8" >
    <SelectedRowStyle BackColor="BurlyWood" />
    <Columns>
    <asp:HyperLinkField DataNavigateUrlFields="pid" 
DataNavigateUrlFormatString=
"~/testing/textbox.aspx?id={0}" 
Text="View Details" />
    <asp:BoundField DataField="pid" HeaderText="ID" />
    <asp:BoundField DataField="pname" HeaderText="Property Name" />
    <asp:ImageField HeaderText="Image" DataImageUrlField="pimage" />
    </Columns>
    </asp:GridView>
    <asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="~/property.mdb" SelectCommand="Select * from pfeed order by pid">
</asp:AccessDataSource>
    <asp:PlaceHolder ID="ph1" runat="server"/>
</div>
    </form>
</body>
</html>


[edit]Code block added, "Treat my content as plain text..." option disabled - OriginalGriff[/edit]
Posted
Updated 12-Jan-12 22:48pm
v2
Comments
Sergey Alexandrovich Kryukov 13-Jan-12 4:58am    
Where is your query? Code? OleDb uses parametrized queries with positional parameters, you should substitute valid number of parameters of valid types.
--SA
Sridhar Patnayak 2-Feb-12 1:17am    
Not provided related code. This code is not related to the specific error

1 solution

You query is missing a value for one of the specified parameters.
OleDbCommand command = new OleDbCommand("SampleProc", connection);
command.CommandType = CommandType.StoredProcedure;

OleDbParameter parameter = command.Parameters.Add(
  "RETURN_VALUE", OleDbType.Integer);
parameter.Direction = ParameterDirection.ReturnValue;

parameter = command.Parameters.Add(
  "@InputParm", OleDbType.VarChar, 12);
parameter.Value = "Sample Value";

parameter = command.Parameters.Add(
  "@OutputParm", OleDbType.VarChar, 28);
parameter.Direction = ParameterDirection.Output;

check this link out as well http://msdn.microsoft.com/en-us/library/yy6y35y8.aspx[^]

This is as far as I can help you without you supplying your actual query or storedproc that your are querying.
 
Share this answer
 
v2
Comments
Sridhar Patnayak 2-Feb-12 1:20am    
This is one scenario to rise this type of error, But their may be some other scenario like forget field while inserting records in db.
Dean Oliver 2-Feb-12 1:22am    
I can only diagnose the problem if the code is supplied though.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900