Updating database date field results in date value of "01/01/1900"

Brand new to this, so please bear with me.

I'm using the following code fragment to update a datetime field on a SQL Server 2005 database table:

cmd.CommandText = "Update Projects Set EntryDate = " & Convert.ToDateTime(txtEntryDate.Text)
cmd.ExecuteNonQuery()

The result of the update operation is the the database field contains the value "1900-01-01 00:00:00:000".  This probably means that I passed nulls to SQL; however, I see a valid date in the txtEntryDate field on my web form (i.e., "06/18/2007").  I also did a "Response.write" to display the txtEntryDate and it looks Okay.

Can someone tell me what I'm doing wrong?

Thanks!

Using Visual Web Developer 2005 Express.

0
pwomack
6/18/2007 7:35:16 PM
asp.net.sql-datasource 29906 articles. 0 followers. Follow

1 Replies
1365 Views

Similar Articles

[PageSpeed] 13

cmd.CommandText = "Update Projects Set EntryDate = @EntryDate"

cmd.Parameters.Add("@EntryDate",datetime).Value=txtEntryDate.Text

cmd.ExecuteNonQuery()

 

0
Motley
6/18/2007 8:01:46 PM
Reply:

Similar Artilces:

Update a date within SQL gives me an error "Can't convert String to Date"
Good afternoon/Morning I am hoping someone can help me with a problem I am having. I am trying to update a date value but I get the convert error. I have tried the following code but with no joy. Can anyone shed some light on what I need to do to enable the converting of a string into Date?private void UpdateSingleItem(string StoredProcedure) { //Connect to stored procedure //Create a DataAdapter, and then provide the name of the stored procedure.SqlDataAdapter MyDataAdapter = new SqlDataAdapter(StoredProcedure, MyConnection); //Set the command type as StoredProcedure.MyData...

How to use Convert date statement in cmdInsert.Parameters.Add("Date",SqlDbType.DateTime).Value = date
HiI am using SQL 2005, VB 2005I am trying to insert a record using parameters using the following code as per MotLey suggestion and it works finestring insertSQL; insertSQL = "INSERT INTO Issue(ProjectID, TypeofEntryID, PriorityID ,Title, Area) VALUES (@ProjectID, @TypeofEntryID, @PriorityID ,@Title, @Area)"; cmdInsert SqlCommand; cmdInsert=new SqlCommand(insertSQL,conn); cmdInsert.Parameters.Add("@ProjectID",SqlDbType.Varchar).Value=ProjectID.Text; My query is how to detail with dates my previous code wasinsertSQL += "convert(datetime,'" + DateTime.Now.ToSt...

What updates "Date Accessed" field?
NW 6.5 SP5 with NSS volume. Notice the "Date Accessed" field of all files are changed all the time and it always have 12:00 a.m. time stamp. We have done some tests and it was not the backup program that touches the date accessed field. There is also no virus scan schedule to scan all files on the network. Can someone provide information how I can tell what process updates the field. I would like to ensure this field indicate when the file was accessed by a user. Regards Che Well, anything that accesses (reads, writes, modifies, etc) the file will update that ...

HELP!! Need to change "Created" date to "Date" for messages
I'm exporting email for a legal request from an account, only for a certain time period and after certain messages have been redacted as they are "closed records" (I'm a local government installation). I'm using the Transend Migrator Forsenic product to export messages from the user's account to a "ereview" account which then I delete the messages not in the time frame requested and then my legal people go though that account and remove "closed records". When everything is ready I then use the Transend product to export the final me...

Default Date 01/01/1900 ro current date
Is there a way to change the PB default date of 01/10/1900? Is it a built-in setup or is there a setting I can change to make it use the current date instead of 10/10/1900? Thanks for your help! No. I believe PB uses an "epoch" integer for internal date storage, and 01-jan-1900 is what 0 translates to. You're just going to have to initialize ate variables as needed. <Anna> wrote in message news:4238932b.391a.1681692777@sybase.com... > Is there a way to change the PB default date of 01/10/1900? > Is it a built-in setup or is there a setting I can change t...

Date Issue
Has anyone run across this problem? I don't remember seeing it prior to 1.0.10: Any date field, i.e. the Expire Date field in the portal settings reverts to the format "8-Oct-2003" and generates the warning "Invalid expiry date!". For example if I go to view the settings for a particular portal, the expire date is in the 'DD-MMM-YYYY' format and won't let me update the settings until I either type a MM-DD-YYYY date in or select one from the calendar. This happens in the module settings as well when there is a date involved. Is this some regional setting I have to...

a-squared "Free" updates... 2006-01-01
a-squared "Free" updates... 2006-01-01 http://www.emsisoft.com/en/ Your updated files list may be different. " Downloading update information ... Downloading Engine ... Added detection for the WMF exploit. The update process was finished successfully. " 2006-01-01 513536 a2kernel.dll 0e8c3233337e6c14eb9a4b8cf70c2e69 *a2kernel.dll This file (although the same size as recently) is new. -- (auto-posted from "ET" (UTC -0400/-0500)) (Language file updates alone will not be posted) (Updates (except .LNG) are "since...

How to change the input behaviour of a field of type "number" in "date"
I have a datawindow with a column object of type "number". What I need is an input behaviour of a date field and then convert the date to a number (seconds since 01.01.1970). I have already the function for the conversion but no idea how to change the input behaviour of the column object. Thank you for any help, Ute In article <3695DE8E.2006@surf24.de>, Ute.Schneider@surf24.de says... > I have a datawindow with a column object of type "number". > What I need is an input behaviour of a date field and then convert the > date to a number (seconds si...

DW "date" datype field & Oracle8 DATE type
Hi there, we're considering adding Oracle8 support to our product but: Is there any way how to overcome the already known issue between Oracle8 DATE type (which is actually "datetime" PB datatype) and PB datawindow field of "date" datatype (e.g. as created while connected to Sybase SQL Anywhere DATE database field)??? I mean without redoing/refreshing all existing DW "date" datatype fields to "datetime" datatype. Platform: Windows NT&95, PB6.5, Oracle8, while using only the ODBC driver (native drivers cannot be used)!!! Thanx for your f...

Convert 01-01-1900 Date string value to NULL
Hi   I have a number of Textboxs on a Formview.   The Textboxs contains Date values.   When I update these dates are saved to SQL Default 1/1/1900.   I know I have to Convert Date string value to NULL before UPDATE query is executed Or write a trigger to replace 1/1/1900 values to null   I cannot find a way of converting Date back to NULL.   Also, I have only written very simple triggers.   Could anyone help me on to how to achieve the above?   Thanks in advance.   Using VB 2005/SQL 2005 Have default datetime value i...

date is 01/01/1900
I am using PB12.1 and MS SQL Server 2008 R2 Express , and I am connect through SNC I have code like::- ls_date = "28/12/2010" format is dd/mm/yyyy date ldt_date ldt_date = date(ls_date) but it gives date=01/01/1900 it means null date and in control panel\reginal setting I change date format to dd/mm/yyyy but problem still, could any one help me thanks I just answered this question in the general section. Please don't crosspost - answers are more useful if the discussion is all in one place. Report Bugs to Sybase: http://case-express.sybase.com/cx/welcome.do ...

date is 01/01/1900
I'm updating a row in sql2k and its updating my date field to 01/01/1900 no matter what I specify. Am I doing this correctly: UPDATE Purchase SET DOP = 25/03/2003 WHERE Code = 'code02' I'm using query analyzer also, same thing, although row updated successfully is 1. > UPDATE Purchase SET DOP = 25/03/2003 WHERE Code = 'code02' try : UPDATE Purchase SET DOP = '25/03/2003' WHERE Code = 'code02' or in access UPDATE Purchase SET DOP = #25/03/2003# WHERE Code = 'code02' though I usually try to use non-ambiguos date formats e.g. UPDATE Purchase SET DOP = '25 Mar...

date is 01/01/1900
I am using PB12.1 and MS SQL Server 2008 R2 Express , and I am connect through SNC I have code like::- ls_date = "28/12/2010" format is dd/mm/yyyy date ldt_date ldt_date = date(ls_date) but it gives date=01/01/1900 it means null date and in control panel\reginal setting I change date format to dd/mm/yyyy but problem still, could any one help me thanks That says the input was not recognized as a valid format - null input would return null. It's a better practice to use PB's date literal format "yyyy-mm-dd" to avoid problems, as the control panel se...

Display Today's date in my "Current Date" parameter field
Hi  I have created a parameter called "Current Date". The type is DateTime.How do I get today's date to show as default in my "Current Date" parameter textbox? In the "Report Parameters" area, I entered =Today for the Non-Queried. I saved the report, did a build and Todays date displayed correctly. When I clicked the "Preview" button, the report automatically ran because theCurrent Date field was completed. However, is their a way to not have the reportrun automatically. In c# u will use System.Datetime.Now for current date in SQL u use...

Web resources about - Updating database date field results in date value of "01/01/1900" - asp.net.sql-datasource

Resources last updated: 11/23/2015 7:57:13 PM