Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. SQL Execution Error Failed to Convert from dateTime to TimeSpan

SQL Execution Error Failed to Convert from dateTime to TimeSpan

Scheduled Pinned Locked Moved Database
questiondatabasehelpcss
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    AAGTHosting
    wrote on last edited by
    #1

    I executed the following query using Visual Basic in the Table Adapter wizard. SELECT less_time, less_day FROM tbl_lessons WHERE (teach_id = 100) AND (less_status = 1) AND (less_time = '1/1/1900 3:00:00 PM') AND (less_day = 2) In visual basic I use @param1, @param2 and @param3 for the teach_id, less_time and less_day. When I ran the query in Visual Basic I get the following error, but when I run the identical query using the SQL Server Express I do not get the error. Has anyone seen this error before? Why does it happen? How do I fix it?

    Error Source: System.Data
    Error Message: Failed to convert paramater value from a dateTime to a timeSpan.

    P 1 Reply Last reply
    0
    • A AAGTHosting

      I executed the following query using Visual Basic in the Table Adapter wizard. SELECT less_time, less_day FROM tbl_lessons WHERE (teach_id = 100) AND (less_status = 1) AND (less_time = '1/1/1900 3:00:00 PM') AND (less_day = 2) In visual basic I use @param1, @param2 and @param3 for the teach_id, less_time and less_day. When I ran the query in Visual Basic I get the following error, but when I run the identical query using the SQL Server Express I do not get the error. Has anyone seen this error before? Why does it happen? How do I fix it?

      Error Source: System.Data
      Error Message: Failed to convert paramater value from a dateTime to a timeSpan.

      P Offline
      P Offline
      Pete OHanlon
      wrote on last edited by
      #2

      Take a look at the parameters that you've generated in the wizard. You'll find that one of them is a TimeSpan; and the code is passing in a DateTime. That's what you need to sort out.

      Deja View - the feeling that you've seen this post before.

      My blog | My articles

      A 1 Reply Last reply
      0
      • P Pete OHanlon

        Take a look at the parameters that you've generated in the wizard. You'll find that one of them is a TimeSpan; and the code is passing in a DateTime. That's what you need to sort out.

        Deja View - the feeling that you've seen this post before.

        My blog | My articles

        A Offline
        A Offline
        AAGTHosting
        wrote on last edited by
        #3

        I looked in the wizard and I can't find a place to select a dataType. One of my table columns is a UDT named time that I created from dateTime. I did not create an assembly. Also the dateTime datatype that I pass in is a dateTime that adds a timespan to change the startTime. Is it possible that the time dataType could cause this? I also increment startTime with timeSpan which is a dateTime dataType in VB.NET. Could this cause the problem?

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups