hayward03
asked on
Date format SQL
Hi,
I am trying to insert a date from a textbox that I have brought in from SQL back into SQL and I keep getting the error:
Conversion failed when converting date and/or time from character string.
-------------------------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- --
This is the code im using to pull the date from SQL to my ASP.NET page
txtDate.Text = DateTime.Parse(newsContent .Rows[0][" date"].ToS tring()).T oShortDate String();
-------------------------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- --
Then I'm using the code belwo to update the date in SQL
DateTime dateNew;
dateNew = DateTime.Parse(txtDate.Tex t);
string query1 = "UPDATE smartChimps_news SET date='" + dateNew + "' WHERE newsid='" + newsid + "'";
I am trying to insert a date from a textbox that I have brought in from SQL back into SQL and I keep getting the error:
Conversion failed when converting date and/or time from character string.
--------------------------
This is the code im using to pull the date from SQL to my ASP.NET page
txtDate.Text = DateTime.Parse(newsContent
--------------------------
Then I'm using the code belwo to update the date in SQL
DateTime dateNew;
dateNew = DateTime.Parse(txtDate.Tex
string query1 = "UPDATE smartChimps_news SET date='" + dateNew + "' WHERE newsid='" + newsid + "'";
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks