I'm having a problem with my code that i've been trying to fix for hours now. Basically, the goal of the program is for users to log in, then they can fill in basically a movie review page. Theoretically every user is only allowed to leave one review for each movie - though I haven't gotten to the validation for that yet. Right now, it just keeps saying that there's no value given for one of the parameters so if anyone could help out that would be amazing.
Code:
<form id="form1" runat="server">
<div>
<asp:GridView ID="GridReview" runat="server" AutoGenerateColumns="False" DataKeyNames="movieid" DataSourceID="SqlDataSource1">
<Columns> <asp:BoundField DataField="movietitle" HeaderText="movietitle" InsertVisible="False" ReadOnly="false" SortExpression="movietitle" />
<asp:BoundField DataField="Username" HeaderText="User" SortExpression="Username" />
<asp:BoundField DataField="review" HeaderText="Review" SortExpression="review" />
<asp:BoundField DataField="rating" HeaderText="Rating" SortExpression="rating" />
</Columns>
</asp:GridView>
<asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" DataKeyNames="movieid" DataSourceID="SqlDataSource1" DefaultMode="Insert" Height="50px" Width="125px" OnItemInserted="DetailsView1_ItemInserted">
<Fields>
<asp:TemplateField HeaderText="MovieTitle" SortExpression="Movieid">
<ItemTemplate>
<asp:DropDownList runat="server" DataSourceID="SqlDataSourceW2" DataTextField="MovieTitle" DataValueField="MovieId"></asp:DropDownList>
<asp:SqlDataSource ID="SqlDataSourceW2" runat="server" ConnectionString="<%$ ConnectionStrings:Database1connectionString %>" ProviderName="<%$ ConnectionStrings:Database1connectionString.ProviderName %>" SelectCommand="SELECT [MovieID], [MovieTitle] FROM [movies_table] ORDER BY [Movietitle]"></asp:SqlDataSource>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="rating" HeaderText="rating" SortExpression="rating" />
<asp:BoundField DataField="review" HeaderText="review" SortExpression="review" />
<asp:CommandField ShowInsertButton="True" />
</Fields>
</asp:DetailsView>
</div>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:Database1ConnectionString %>" SelectCommand="select * from REVIEW_TABLE where (movieid = ?)" InsertCommand="insert [REVIEW_TABLE]
([Username], [MovieID], [MovieTitle], [Rating], [Review])
values (?,?,?,?,?)" ProviderName="<%$ ConnectionStrings:Database1ConnectionString.ProviderName %>" >
<InsertParameters>
<asp:SessionParameter Name="Username" SessionField="Username" Type="String" />
<asp:Parameter Name="movieid" Type="String" />
<asp:Parameter Name="movietitle" Type="String" />
<asp:Parameter Name="rating" Type="String" />
<asp:Parameter Name="review" Type="String" />
</InsertParameters>
</asp:SqlDataSource>
<asp:Label ID="LabelError" runat="server"></asp:Label>
</form>
here's the code behind
protected void Page_Load(object sender, EventArgs e)
{
if (Session["firstname"] == null)
{
Response.Redirect("login.aspx");
Session["UserName"] = HttpContext.Current.User.Identity.Name;
}
}
protected void DetailsView1_ItemInserted(object sender, DetailsViewInsertedEventArgs e)
{
GridReview.DataBind();
}
and here's the error I keep getting
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:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[OleDbException (0x80040e10): No value given for one or more required parameters.]
System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(OleDbHResult hr) +1144656
System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult) +247
System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult) +208
System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult) +58
System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method) +162
System.Data.OleDb.OleDbCommand.ExecuteReader(CommandBehavior behavior) +110
System.Data.OleDb.OleDbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior) +9
System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +139
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +136
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable) +86
System.Web.UI.WebControls.SqlDataSourceView.ExecuteSelect(DataSourceSelectArguments arguments) +1474
System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +22
System.Web.UI.WebControls.DataBoundControl.PerformSelect() +143
System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +74
System.Web.UI.WebControls.GridView.DataBind() +9
System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound() +114
System.Web.UI.WebControls.CompositeDataBoundControl.CreateChildControls() +75
System.Web.UI.Control.EnsureChildControls() +92
System.Web.UI.Control.PreRenderRecursiveInternal() +42
System.Web.UI.Control.PreRenderRecursiveInternal() +160
System.Web.UI.Control.PreRenderRecursiveInternal() +160
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +883
What I have tried:
honestly i've lost track of all the things i've tried at this point.