Click here to Skip to main content
15,890,897 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
Id      Date
1   1/08/2012
2   13/08/2012
3   14/08/2012

when i am select record '3' update i need change the date today
Posted
Updated 22-Aug-12 0:45am
v2
Comments
Christian Graus 22-Aug-12 6:39am    
This makes literally zero sense. Try to come up with a meaningful subject and meaningful tags. This has nothing to do with ASP.NET, even if you're using it. You want to change the date ? 'Select 3' how exactly ? In what context ?
ridoy 22-Aug-12 6:45am    
be specific for your question ad problem you face..
2011999 22-Aug-12 6:46am    
i need code for the .CS file

insert is working fine today date; update is not working.

1 solution

I guess you are having dropdown with values 1,2,3 etc which is ID Column.,


In your dropdown selected index changed event,

Write a new sql command to update

C#
SqlCommand cmd=new SqlCommand("update tbl set Date=@Date where Id=@Id",connection1);
cmd.Parameters.AddWithValue("@Date",DateTime.Now);
cmd.Parameters.AddWithValue("@Id",Convert.ToInt32(cmb.SelectedValue.ToString()));
connection1.Open();
cmd.ExecuteNonquery();
connection1.Close();
 
Share this answer
 
Comments
ridoy 22-Aug-12 7:08am    
right solution..+5

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900