473,382 Members | 1,442 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

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

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

Aug 28 '06 #1
5 1587
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" <st***********@yahoo.comwrote in message
news:11**********************@m73g2000cwd.googlegr oups.com...
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

Aug 28 '06 #2
"Steve Kershaw" <st***********@yahoo.comwrote in message
news:11**********************@m73g2000cwd.googlegr oups.com...
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()
Aug 28 '06 #3
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" <st***********@yahoo.comwrote in message
news:11**********************@m73g2000cwd.googlegr oups.com...
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
Aug 29 '06 #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" <st***********@yahoo.comwrote in message
news:11**********************@m73g2000cwd.googlegr oups.com...
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
Aug 29 '06 #5
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" <st***********@yahoo.comwrote in message
news:11**********************@m73g2000cwd.googlegr oups.com...
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()
Aug 29 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Loi Tan Vo | last post by:
Hi, I have a text file that contains a date column. The text file will be imported to database in SQL 2000 server. After to be imported, I want to convert the date column to date type. For...
8
by: Manish Jain | last post by:
Platform : ASP.Net/C# void SomeFunction(DateTime date) { string text = date.ToString(); //This crashes if date is null } I am using a construct similar to above. I want to check if the date...
0
by: Steve Kershaw | last post by:
Hi, I have a table in a SQL Server 2005 database that has a column of type "datetime". From a C# program I need to insert todays date into this column like so: gridAdapter.InsertNewGridID(...
2
by: TBoon | last post by:
I have a vb.net program to read DATETIME column from MSSQL and write to a TXT file. And I notice that the DATETIME format in the TXT file changed according to my machine datetime setting in...
4
by: =?Utf-8?B?QmFidU1hbg==?= | last post by:
Hi, I have a GridView and a SqlDataSource controls on a page. The SqlDataSource object uses stored procedures to do the CRUD operations. The DataSource has three columns one of which -...
6
by: Manikandan | last post by:
Hi, I need to insert the datetime with milliseconds value into a datarow. My code as below DataTable testDataTable=new DataTable(); testDataTable.Columns.Add("updatedDateTime",...
4
by: Manikandan | last post by:
Hi, I'm inserting a datetime values into sql server 2000 from c# SQL server table details Table name:date_test columnname datatype No int date_t DateTime ...
2
by: rhaazy | last post by:
I need to know how I can format a string in C# to get the current date/ time, so that I can do a comparison against a date time column in MS SQL Server 2005. The date/time column in the database...
11
by: =?Utf-8?B?UGFvbG8=?= | last post by:
I have a SQL database table with rows in which the primary key is a DateTime type (although I don't use the Time part). Have added numerous rows and now want to delete one so I enter the date...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.