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. General Programming
  3. Visual Basic
  4. Saving Date from picker??

Saving Date from picker??

Scheduled Pinned Locked Moved Visual Basic
helpquestion
2 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.
  • H Offline
    H Offline
    hounetdev
    wrote on last edited by
    #1

    Hello, I am trying to save the date to a table from a date picker so that the next time the form is open it will have the last date picked which i will call form the table and assign it to the datepicker as the value. the problem i am having is that when i insert the date into the table which the field is formated to Date i get 12/30/1899 for every date that is inserted. Can someone tell me if there is an easier way to do this or how I Can fix this problem. below is the code i am using. Thanks, Santana 'delete old dates and Saves Dates to date table Dim startdate As Date Dim enddate As Date startdate = pkrstartdate.Text enddate = pkrenddate.Text datedap.DeleteCommand.CommandText = "Delete * From datetbl" datedap.DeleteCommand.ExecuteNonQuery() datedap.InsertCommand.CommandText = "Insert into datetbl (startdate,enddate) values (" & startdate & "," & enddate & ")" datedap.InsertCommand.ExecuteNonQuery() MsgBox(startdate) MsgBox(enddate) newMDRConn.Close()

    D 1 Reply Last reply
    0
    • H hounetdev

      Hello, I am trying to save the date to a table from a date picker so that the next time the form is open it will have the last date picked which i will call form the table and assign it to the datepicker as the value. the problem i am having is that when i insert the date into the table which the field is formated to Date i get 12/30/1899 for every date that is inserted. Can someone tell me if there is an easier way to do this or how I Can fix this problem. below is the code i am using. Thanks, Santana 'delete old dates and Saves Dates to date table Dim startdate As Date Dim enddate As Date startdate = pkrstartdate.Text enddate = pkrenddate.Text datedap.DeleteCommand.CommandText = "Delete * From datetbl" datedap.DeleteCommand.ExecuteNonQuery() datedap.InsertCommand.CommandText = "Insert into datetbl (startdate,enddate) values (" & startdate & "," & enddate & ")" datedap.InsertCommand.ExecuteNonQuery() MsgBox(startdate) MsgBox(enddate) newMDRConn.Close()

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      mariscal wrote: datedap.InsertCommand.CommandText = "Insert into datetbl (startdate,enddate) values (" & startdate & "," & enddate & ")" Stringing together an SQL statement like this is a bad idea. Instead, use a stored procedure that can validate what your putting into the table. This will also give you the ability to use SQLParameter objects that can properly convert the date to an SQL compatible DBDate and back again. RageInTheMachine9532

      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