Calendar Date Parameter to SP

Posted on 2006-05-10
Last Modified: 2008-03-10
What am I doing wrong?

objcmd.Parameters.Add("@SelectedDate", SqlDbType.DateTime).Value = DateTime.Parse(String.Format("{0}/{1}/{2}", ("seldate")))

<tr align=center><td>
<form runat=server>      
<asp:Calendar id="seldate" runat="server" OnSelectionChanged="prntl">
Question by:net_susan
    LVL 11

    Assisted Solution

    String.Format("{0}/{1}/{2}"  <- this is the problem.

    try objcmd.Parameters.Add("@SelectedDate", SqlDbType.DateTime).Value = DateTime.Parse(String.Format("{0}", ("seldate"))), and it will work fine.

    What datetime format are you trying to have?

    LVL 7

    Accepted Solution

    If you are passing a value from a calendar is there a reason you converting parse'ing from string to datetime?

    objcmd.parameters.AddWithValue("@SelectedDate", seldate.SelectedDate)

    LVL 1

    Author Comment

    I think this worked:

     objcmd.Parameters.Add("@SelectedDate", SqlDbType.DateTime).Value=(seldate.SelectedDate)
    LVL 1

    Author Comment

    Yes, it worked. Thank you!

    Featured Post

    Maximize Your Threat Intelligence Reporting

    Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

    Join & Write a Comment

    Suggested Solutions

    AJAX ModalPopupExtender has a required property "TargetControlID" which may seem to be very confusing to new users. It means the server control that will be extended by the ModalPopup, for instance, if when you click a button, a ModalPopup displays,…
    I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now