Click here to Skip to main content
15,897,704 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hey..
plz give me the code, when i am click on update button, the data will be stored in database, but not use gridview, update button can use in form
plz help me.. thanks :)
Posted
Comments
[no name] 2-Feb-13 2:41am    
Elaborate your question
Chintan Parekh7 2-Feb-13 2:48am    
default.aspx file i have put one button, i have not use gridview so whan i am click the update button the data will be stored in database
[no name] 2-Feb-13 2:52am    
You can easily get values from controls (i.e TextBox, Checkbox etc) and use 'em in Update query... As simple is that!
Chintan Parekh7 2-Feb-13 2:57am    
but i have no idea for that, how the code will be write?
and i have also use SQL Server for save the data, so plz help me out.
Nandakishore G N 2-Feb-13 3:28am    
instead of posting the question try to google it....i am sure you'll get number of examples

1 solution

Try:
C#
using (SqlConnection con = new SqlConnection(strConnect))
    {
    con.Open();
    using (SqlCommand com = new SqlCommand("UPDATE myTable SET myColumn1=@C1, myColumn2=@C2 WHERE Id=@ID", con))
        {
        com.Parameters.AddWithValue("@ID", id);
        com.Parameters.AddWithValue("@C1", myValueForColumn1);
        com.Parameters.AddWithValue("@C2", myValueForColumn2);
        com.ExecuteNonQuery();
        }
    }
 
Share this answer
 

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