problem in date..

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • madhurjya
    New Member
    • Nov 2007
    • 14

    #1

    problem in date..

    please help...


    i tried to store a date in sql server 2000 which field format is datetime..
    i use the 'cdate' function.with following coding

    dim a as string
    a = DateTime.Now.To ShortDateString

    and cdate(a) store the date to database.


    but after the every execution it store only the 1/1/1900 12:00:00 AM even my system date is also ok.
  • mzmishra
    Recognized Expert Contributor
    • Aug 2007
    • 390

    #2
    I have tried your code and it is returning me correct Date .
    Dim a As String
    Dim d
    a = DateTime.Now.To ShortDateString ()
    d = CDate(a)

    Are you doing someting before inserting into database

    Comment

    • madhurjya
      New Member
      • Nov 2007
      • 14

      #3
      Originally posted by mzmishra
      I have tried your code and it is returning me correct Date .
      Dim a As String
      Dim d
      a = DateTime.Now.To ShortDateString ()
      d = CDate(a)

      Are you doing someting before inserting into database



      ya i made connection string even other all the fields are nicely placed except date.

      Comment

      • mzmishra
        Recognized Expert Contributor
        • Aug 2007
        • 390

        #4
        can u paste your insert query here

        Comment

        • madhurjya
          New Member
          • Nov 2007
          • 14

          #5
          Originally posted by mzmishra
          can u paste your insert query here
          Dim a As Date
          a = DateTime.Now.To ShortDateString
          MsgBox(DateTime .Today)
          MsgBox(DateTime .Now.ToShortDat eString)
          con = New SqlConnection(" server=nic-server2;databas e=idsp;uid='sa' ;pwd=''")
          cmd = New SqlCommand("ins ert into daily values(" & a & "," & TextBox2.Text & "," & TextBox7.Text & "," & TextBox3.Text & "," & TextBox1.Text & "," & TextBox4.Text & "," & TextBox6.Text & "," & TextBox5.Text & ")", con)

          Comment

          Working...