Basic Date Picker Forums

Welcome to Basic Date Picker Forums Sign in | Join | Help
in Search

No mapping exists from object type System.TimeSpan

Last post 01-25-2007, 5:33 AM by geoffrey.mcgill. 3 replies.
Sort Posts: Previous Next
  •  01-07-2007, 8:08 PM 982

    No mapping exists from object type System.TimeSpan

    I'm getting this error on an insert, using the BDT for a Date field and the BTT for a Time field (SQL Server):
    No mapping exists from object type System.TimeSpan to a known managed provider native type.

    here's the insert statement:
    Dim MySQL as string = "Insert into CalSchedule (CalDate, Title, Schedule, CalTime) Values (@CalDate, @Title, @Schedule, @CalTime)"
    Dim MyConn as New SQLConnection(strConn)
    Dim Cmd as New SQLCommand(MySQL, MyConn)
    With Cmd.Parameters
     .Add(New SQLParameter("@CalDate", frmCalDate.SelectedDate))
     .Add(New SQLParameter("@Title", frmTitle.text))
     .Add(New SQLParameter("@Schedule", frmSchedule.text))
     .Add(New SQLParameter("@CalTime", frmCalTime.Selectedtime))
    End With
    MyConn.Open()
    cmd.ExecuteNonQuery()
    lblResults.Text="Your Calendar Item has been successfully entered."
    MyConn.Close

    frmCalDate is the BDT, and frmCalTime is the BTT - both fields in the SQL Server table are DateTime fields

    Any ideas, here?

  •  01-09-2007, 4:24 AM 1006 in reply to 982

    Re: No mapping exists from object type System.TimeSpan

    Hi ElmoWatson,

    We have a couple suggestions.

    Option 1. How about adding the frmCalDate and frmCalTime together and then storing into one database field? Based on your code provided this would be simple, just set the TimePicker property of the DatePicker with the id of the TimePicker and you should be good to go. Example:

    <BDP:BasicDatePicker ID="frmCalDate" runat="server" TimePicker="frmCalTime" /> <BDP:TimePicker ID="frmCalTime" runat="server" />


    Once you set the TimePicker property, the two controls are linked and the SelectedDate property will automatically handle setting/getting of the SelectedTime. The date picker will add the two values together and return one DateTime value. Your frmCalDate field will now contain both the Date & Time values.

    If you have null/DBNull values in your database, you could bind to the SelectedValue property. The SelectedValue property will properly handle any null values, whereas the SelectedDate property requires a DateTime object, which can not be null.

    Option 2. Change the frmCalTime field in the database to accept a string instead of a Date and then set/get the SelectedValue property of the TimePicker. The SelectedValue property "should" automatically convert the time value string into a TimeSpan object. The SelectedValue property will return an Object, so just get .SelectedTimeFormatted when filling your @CalTime SQLParameter. Example:

    .Add(New SQLParameter("@CalTime", frmCalTime.SelectedTimeFormatted))

    Calling .ToString on the SelectedTime should also work. Example:

    .Add(New SQLParameter("@CalTime", frmCalTime.SelectedTime.ToString()))



    Option #1 above is definitely preferred over option #2.

    I hope this helps answer your question.

    I apologize for the late response to your support request. We've been swamped coming off the holidays and preparing for our version 1.3 release, which we released yesterday.

    We would highly recommend upgrading to version 1.3 of the controls if you have not already done so. You can download our latest installer or manual installation package at http://www.basicdatepicker.com/download/



    Thanks,
    Geoffrey McGill
    ----------------------------------------
    Coolite Inc.
    Email: support [at] coolite [dot] com
    Phone: +1(888)775-5888
  •  01-12-2007, 7:54 AM 1026 in reply to 982

    Re: No mapping exists from object type System.TimeSpan

    Hi ElmoWatson,

    How are things going with the TimePicker and databinding? Was our previous post helpful?

    Let us know if you have any further questions or comments and we will do our best to help out.


    Thanks,
    Geoffrey McGill
    ----------------------------------------
    Coolite Inc.
    Email: support [at] coolite [dot] com
    Phone: +1(888)775-5888
  •  01-25-2007, 5:33 AM 1053 in reply to 1006

    Re: No mapping exists from object type System.TimeSpan

    Hi ElmoWatson,

    If you wish to just display a TimePicker and no DatePicker, we recommend adding a DatePicker, but setting the Visible property to false. Example:

    <BDP:BasicDatePicker
        ID="frmCalDate"
        runat="server"
        TimePicker="frmCalTime"
        Visible="false"
        />
    <BDP:TimePicker
        ID="frmCalTime"
        runat="server"
        />


    Then bind to the date pickers SelectedDate or SelectedValue property. The date picker will be hidden.

    You will also have to change your database columns DataType to 'datetime'.

    Hope this helps.


    Thanks,
    Geoffrey McGill
    ----------------------------------------
    Coolite Inc.
    Email: support [at] coolite [dot] com
    Phone: +1(888)775-5888
View as RSS news feed in XML
 
Powered by Community Server, by Telligent Systems