How can I save a DateTime from my C# program into a SQL Server (datetime) database column.

Discussion in 'ASP .Net' started by Steve Kershaw, Aug 28, 2006.

  1. Hi I have a problem in that I need to save the creation date of a new
    record to a column. The column is set up as a datetime type and the C#
    date is a DateTime type. I keep on getting an error that states that
    I'm trying to write to a SQL column that's set up as an 'int'.

    Is there anyway to do this?

    Thanks very much for your help.
    Steve
    Steve Kershaw, Aug 28, 2006
    #1
    1. Advertising

  2. There must be something else going on, but since you did not post code or a
    reproduceable case, it's hard to say. YOu also didn't post the exact error
    message.

    "Steve Kershaw" <> wrote in message
    news:...
    > Hi I have a problem in that I need to save the creation date of a new
    > record to a column. The column is set up as a datetime type and the C#
    > date is a DateTime type. I keep on getting an error that states that
    > I'm trying to write to a SQL column that's set up as an 'int'.
    >
    > Is there anyway to do this?
    >
    > Thanks very much for your help.
    > Steve
    >
    Marina Levit [MVP], Aug 28, 2006
    #2
    1. Advertising

  3. Steve Kershaw

    Mark Rae Guest

    "Steve Kershaw" <> wrote in message
    news:...

    > Is there anyway to do this?


    If the value is always going to be the current date & time, set a default on
    the column of getdate()
    Mark Rae, Aug 28, 2006
    #3
  4. I did post an exact error with code yesterday and I got NO RESPONSE. So
    I thought I'd simplify the statement of the problem, maybe that would
    help.

    If you don't know how to fix the problem then jumping on the newbees
    will only insure that they go somewhere else to get their answers.

    Steve

    Marina Levit [MVP] wrote:
    > There must be something else going on, but since you did not post code or a
    > reproduceable case, it's hard to say. YOu also didn't post the exact error
    > message.
    >
    > "Steve Kershaw" <> wrote in message
    > news:...
    > > Hi I have a problem in that I need to save the creation date of a new
    > > record to a column. The column is set up as a datetime type and the C#
    > > date is a DateTime type. I keep on getting an error that states that
    > > I'm trying to write to a SQL column that's set up as an 'int'.
    > >
    > > Is there anyway to do this?
    > >
    > > Thanks very much for your help.
    > > Steve
    > >
    Steve Kershaw, Aug 29, 2006
    #4
  5. I did post an exact error with code yesterday and I got NO RESPONSE. So
    I thought I'd simplify the statement of the problem, maybe that would
    help.

    If you don't know how to fix the problem then jumping on the newbees
    will only insure that they go somewhere else to get their answers.

    Steve

    Marina Levit [MVP] wrote:
    > There must be something else going on, but since you did not post code or a
    > reproduceable case, it's hard to say. YOu also didn't post the exact error
    > message.
    >
    > "Steve Kershaw" <> wrote in message
    > news:...
    > > Hi I have a problem in that I need to save the creation date of a new
    > > record to a column. The column is set up as a datetime type and the C#
    > > date is a DateTime type. I keep on getting an error that states that
    > > I'm trying to write to a SQL column that's set up as an 'int'.
    > >
    > > Is there anyway to do this?
    > >
    > > Thanks very much for your help.
    > > Steve
    > >
    Steve Kershaw, Aug 29, 2006
    #5
  6. Mark,

    Ok so how do I set the current date & time on a column in SQL Server
    2005? I have tried right click-Default Value or Binding, but to no
    avail!

    Thanks for your help.

    Steve

    Mark Rae wrote:
    > "Steve Kershaw" <> wrote in message
    > news:...
    >
    > > Is there anyway to do this?

    >
    > If the value is always going to be the current date & time, set a default on
    > the column of getdate()
    Steve Kershaw, Aug 29, 2006
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Harry Zoroc
    Replies:
    1
    Views:
    933
    Gregory Vaughan
    Jul 12, 2004
  2. Christos TZOTZIOY Georgiou
    Replies:
    3
    Views:
    704
    Christos TZOTZIOY Georgiou
    Sep 13, 2003
  3. Steve Kershaw
    Replies:
    0
    Views:
    10,796
    Steve Kershaw
    Aug 26, 2006
  4. Bhuwan Bhaskar
    Replies:
    5
    Views:
    576
    Bhuwan Bhaskar
    Oct 21, 2007
  5. Replies:
    2
    Views:
    433
Loading...

Share This Page