I have an issue with this code.
<asp:SqlDataSource ID="ReservationRadSchedualerSqlDataSource" OnDeleting="ReservationRadSchedualerSqlDataSource_Deleting" runat="server" ConnectionString="<%$ ConnectionStrings:NMRconstr %>"
SelectCommand="GetReservationAppointments" SelectCommandType="StoredProcedure"
InsertCommand="INSERT INTO [ReservationAppointments] (Subject , Description, Start, [End], RecurrenceRule , Username , MachinePKID) VALUES (@Subject , @Description, @Start, @End, @RecurrenceRule , @username , @macPKID)"
UpdateCommand="EXEC UpdateReservationAppointment @Subject , @Description , @Start , @End , @RecurrenceRule , @username , @ID , @macPKID"
DeleteCommand="EXEC DeleteAppointmentByUser @ID , @username"
>
<UpdateParameters>
<asp:ControlParameter ControlID="ReservationScedhualerSelectMachineRadDropDownList" Name="macPKID" PropertyName="SelectedValue" Type="Int32" />
</UpdateParameters>
<SelectParameters>
<asp:ControlParameter ControlID="ReservationScedhualerSelectMachineRadDropDownList" Name="macPKID" PropertyName="SelectedValue" Type="Int32" />
</SelectParameters>
<InsertParameters>
<asp:SessionParameter Name="username" SessionField="username" Type="string" />
<asp:ControlParameter ControlID="ReservationScedhualerSelectMachineRadDropDownList" Name="macPKID" PropertyName="SelectedValue" Type="Int32" />
</InsertParameters>
<DeleteParameters>
<asp:SessionParameter Name="username" SessionField="username" Type="string" />
</DeleteParameters>
</asp:SqlDataSource>
In the delete command parameters, the session username parameter causes an error "Must declare the scalar variable "@username"."
I tried to figure out what I did wrong but I cant find it. The weird thing is that it works for INSERT and UPDATE commands, but not for the DELETE command.
I will be happy to get your help to figure out what is causing this error.
Thanks.
Everything seems in order with the .Net side. Can you post the SQL for the DeleteAppointmentByUser function? Suspect the issue is in there.