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
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
VasanthPosted Mar 31, 2010, 1:57 AM
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.
Hirendra SisodiyaPosted Mar 31, 2010, 1:39 AM
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