Hi guys.
here is my sqlcommand Code
And here is code behinde
How ican Insert? Insert occure right and okey! but UserID field is null!?
how i can fill UserID column in database with Session?
(Update Select and Delete Is absolutely okey)
tnx guys
here is my sqlcommand Code
<asp:SqlDataSource ID="SqlDataSource1" runat="server" |
ConnectionString="<%$ ConnectionStrings:ConnectionString %>" |
SelectCommand="SELECT AppointmentID, Start, [End], Subject, Due, Priority, UserID FROM Appointments_DragAndDrop WHERE (Start IS NOT NULL) AND ([End] IS NOT NULL) AND (UserID = @UserID)" |
InsertCommand="INSERT INTO Appointments_DragAndDrop(Subject, Start, [End], UserID) VALUES (@Subject, @Start, @End , @UserID)" |
UpdateCommand="UPDATE [Appointments_DragAndDrop] SET [Start] = @Start, [End] = @End, [Subject] = @Subject WHERE AppointmentID = @AppointmentID" |
DeleteCommand="DELETE FROM [Appointments_DragAndDrop] WHERE [AppointmentID] = @AppointmentID"> |
<InsertParameters> |
<asp:Parameter Name="Subject" Type="String" /> |
<asp:Parameter Name="Start" Type="DateTime" /> |
<asp:Parameter Name="End" Type="DateTime" /> |
<asp:Parameter Name="UserID" /> |
</InsertParameters> |
<UpdateParameters> |
<asp:Parameter Name="Start" Type="DateTime" /> |
<asp:Parameter Name="End" Type="DateTime" /> |
<asp:Parameter Name="Subject" Type="String" /> |
<asp:Parameter Name="AppointmentID" Type="Int32" /> |
</UpdateParameters> |
<SelectParameters> |
<asp:SessionParameter DefaultValue="" Name="UserID" SessionField="UserID" /> |
</SelectParameters> |
<DeleteParameters> |
<asp:Parameter Name="AppointmentID" Type="Int32" /> |
</DeleteParameters> |
</asp:SqlDataSource> |
private void HandleSchedulerDrop(int id, string subject, string targetSlotIndex) |
{ |
RadScheduler1.Rebind(); |
ISchedulerTimeSlot slot = RadScheduler1.GetTimeSlotFromIndex(targetSlotIndex); |
TimeSpan duration = TimeSpan.FromHours(1); |
if (slot.Duration == TimeSpan.FromDays(1)) |
{ |
duration = slot.Duration; |
} |
ScheduleAppointment(id, subject, slot.Start, slot.Start.Add(duration), Session["UserID"].ToString()); |
} |
private void ScheduleAppointment(int id, string subject, DateTime start, DateTime end,string UserID) |
{ |
IDataSource dataSource = SqlDataSource1; |
DataSourceView view = dataSource.GetView("DefaultView"); |
IOrderedDictionary data = new OrderedDictionary(); |
data.Add("Subject", subject); |
data.Add("Start", start); |
data.Add("End", end); |
data.Add("UserID", UserID); |
IDictionary keys = new OrderedDictionary(); |
keys.Add("AppointmentID", id); |
view.Update(keys, data, new OrderedDictionary(), OnDataSourceOperationComplete); |
} |
private static bool OnDataSourceOperationComplete(int count, Exception e) |
{ |
if (e != null) |
{ |
throw e; |
} |
return true; |
} |
how i can fill UserID column in database with Session?
(Update Select and Delete Is absolutely okey)
tnx guys