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. Web Development
  3. ASP.NET
  4. problem with date

problem with date

Scheduled Pinned Locked Moved ASP.NET
helpcsharpasp-netdatabasetools
8 Posts 3 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.
  • N Offline
    N Offline
    n_gchaitra
    wrote on last edited by
    #1

    hi, I am working in asp.net 2.0 with vb script. I have few projects which were working fine. But suddent from last few days all are giving the error that is related to date function. Date is not getting stored in database. It gives the error that string cant be converted to date. But it was working fine. and also when i select data from database to bind in a datatagrid then also it is giving the same error. What might be the reason? The datatype in database is DateTime. The syntax i am using is text1.text=calendar1.selecteddate insert table1(ddate) values ('" & text1.text.trim & "')

    Chaitra N

    C G 2 Replies Last reply
    0
    • N n_gchaitra

      hi, I am working in asp.net 2.0 with vb script. I have few projects which were working fine. But suddent from last few days all are giving the error that is related to date function. Date is not getting stored in database. It gives the error that string cant be converted to date. But it was working fine. and also when i select data from database to bind in a datatagrid then also it is giving the same error. What might be the reason? The datatype in database is DateTime. The syntax i am using is text1.text=calendar1.selecteddate insert table1(ddate) values ('" & text1.text.trim & "')

      Chaitra N

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      You never use vbscript with ASP.NET. Well, if you are, you're using it on the client, and you shouldn't, because it ties you to IE. What is the string that it can't convert ? Have you checked in the debugger ? Have your locale settings changed ?

      Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

      N 1 Reply Last reply
      0
      • C Christian Graus

        You never use vbscript with ASP.NET. Well, if you are, you're using it on the client, and you shouldn't, because it ties you to IE. What is the string that it can't convert ? Have you checked in the debugger ? Have your locale settings changed ?

        Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

        N Offline
        N Offline
        n_gchaitra
        wrote on last edited by
        #3

        The project had been developed with VBScript. it says string "" cannot be converted to type date and in some areas char cannot be converted to type date I have not changed anything with my local system

        Chaitra N

        C 1 Reply Last reply
        0
        • N n_gchaitra

          The project had been developed with VBScript. it says string "" cannot be converted to type date and in some areas char cannot be converted to type date I have not changed anything with my local system

          Chaitra N

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          So, it is ASP.NET, but uses VBSCript on the client side ? you know you can change to javascript on a page by page basis, right ? VBScript will only run in IE. If you have an empty string, it plainly cannot be converted to a date, you need to fix your code so the string is not empty.

          Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

          N 1 Reply Last reply
          0
          • N n_gchaitra

            hi, I am working in asp.net 2.0 with vb script. I have few projects which were working fine. But suddent from last few days all are giving the error that is related to date function. Date is not getting stored in database. It gives the error that string cant be converted to date. But it was working fine. and also when i select data from database to bind in a datatagrid then also it is giving the same error. What might be the reason? The datatype in database is DateTime. The syntax i am using is text1.text=calendar1.selecteddate insert table1(ddate) values ('" & text1.text.trim & "')

            Chaitra N

            G Offline
            G Offline
            ganeshkuppuswamy
            wrote on last edited by
            #5

            try to use convert function to convert string to datatime format before saving to database

            ganeshk

            N 1 Reply Last reply
            0
            • C Christian Graus

              So, it is ASP.NET, but uses VBSCript on the client side ? you know you can change to javascript on a page by page basis, right ? VBScript will only run in IE. If you have an empty string, it plainly cannot be converted to a date, you need to fix your code so the string is not empty.

              Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

              N Offline
              N Offline
              n_gchaitra
              wrote on last edited by
              #6

              I tried. This will give the following error. The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.

              Chaitra N

              1 Reply Last reply
              0
              • G ganeshkuppuswamy

                try to use convert function to convert string to datatime format before saving to database

                ganeshk

                N Offline
                N Offline
                n_gchaitra
                wrote on last edited by
                #7

                Are u asking me to use cdate function?

                Chaitra N

                G 1 Reply Last reply
                0
                • N n_gchaitra

                  Are u asking me to use cdate function?

                  Chaitra N

                  G Offline
                  G Offline
                  ganeshkuppuswamy
                  wrote on last edited by
                  #8

                  Fetch the string value and using pares method as coded below you can convert string to date datatype vb Code Dim s As String = TextBox1.Text Dim d As Date = Date.Parse(s) Response.Write(d)

                  ganeshk

                  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