helllo all
I have Table1
No Date
1 2/11/2010
//-------------------------
my question is how to set the Date field back to Null
(using c# code)
tq denny
How to set date field to Null
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Hirendra SisodiyaRank #258 · 9.8K reputationPosted Mar 30, 2010, 9:39 PM EDT
if you want to reset date field on the basis of 'No' field, you need to execute query like this:
update table1 set date=Null where No=1
and if you want to reset all date field, use this query
update table1 set date=Null
thanks
Please mark as answere if it helps
VasanthRank #1,486 · 1.1K reputationPosted Mar 30, 2010, 9:57 PM EDT
Update Table1 set [Date] = NULL where [No] = 1
Pass the query through command text and execute the query. Then you can able to see what you're expecting.
[ C# Code ]
SqlConnection conn= new SqlConnection("
SqlCommand cmd = new SqlCommand();
For using stored procedure :
-------------------------------------
cmd.CommandText = "< StoredProcedure Name >";
cmd.CommandType = CommandType.StoredProcedure;
cmd.Connection = conn;
conn.Open();
int rowsAffected = cmd.ExecuteNonQuery();
conn.Close();
For using Command Text:
-------------------------------------
cmd.CommandText = "Update Table1 set [Date] = NULL where [No] = 1>";
cmd.CommandType = CommandType.Text;
cmd.Connection = conn;
conn.Open();
int rowsAffected = cmd.ExecuteNonQuery();
conn.Close();
Please mark as answer if it helps you.