PC Review


Reply
Thread Tools Rate Thread

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

 
 
Steve Kershaw
Guest
Posts: n/a
 
      28th Aug 2006
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

 
Reply With Quote
 
 
 
 
Marina Levit [MVP]
Guest
Posts: n/a
 
      28th Aug 2006
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>



 
Reply With Quote
 
Mark Rae
Guest
Posts: n/a
 
      28th Aug 2006
"Steve Kershaw" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...

> 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()


 
Reply With Quote
 
Steve Kershaw
Guest
Posts: n/a
 
      29th Aug 2006
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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > 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
> >


 
Reply With Quote
 
Steve Kershaw
Guest
Posts: n/a
 
      29th Aug 2006
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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > 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
> >


 
Reply With Quote
 
Steve Kershaw
Guest
Posts: n/a
 
      29th Aug 2006
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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>
> > 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()


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Detecting database column data type of smalldatetime vs. datetime? Jen Microsoft ADO .NET 3 8th Aug 2007 08:44 AM
Millisecond values missing when inserting datetime into datetime column of sql Server Manikandan Microsoft C# .NET 4 18th Jul 2007 08:59 PM
How do you save a (C#) DateTime into a SQL Server datetime column? Steve Kershaw Microsoft ASP .NET 0 26th Aug 2006 06:59 AM
Inserting C# datetime milliseconds into sql Server DateTime tk042383 Microsoft ADO .NET 2 4th May 2004 04:28 PM
Query on Time part of SQL Server DateTime column Nick Carter Microsoft ADO .NET 0 17th Jul 2003 09:30 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:13 AM.