Click here to Skip to main content
15,892,059 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
now i trying web based appliaction please let me know, how to update the data from textbox to database sql, and how to delete the data from database and also check it its available or not?.

Please advice.....
[DELETED]@gmail.com
selvakumar v

[edit]Email address removed, tags set - OriginalGriff[/edit]
Posted
Updated 5-May-12 6:11am
v2
Comments
OriginalGriff 5-May-12 12:12pm    
Never post your email address in any forum, unless you really like spam! If anyone replies to you, you will receive an email to let you know

Hi ,
Check this
C#
protected void Button1_Click(object sender, EventArgs e)
{
    using (
       SqlConnection con =
           new SqlConnection(ConfigurationManager.ConnectionStrings["testConnectionString"].ConnectionString))
    {
        con.Open();
        using (SqlCommand cmd = new SqlCommand("UPDATE dbo.cate  SET cate = @cate , chk = @chk  where id  = @id", con))
        {
            cmd.Parameters.AddWithValue("@cate", txt1.Text);

            cmd.Parameters.AddWithValue("@chk", chk.Checked);

            cmd.Parameters.AddWithValue("@id", lbl1.Text);
            cmd.ExecuteNonQuery();
        }
    }
}

Best Regards
M.Mitwalli
 
Share this answer
 
use update query

SQL
update tablename set columnname='value of textbox' where condition

--to check use if Exist keywrod in stored procedure

if Exists(Select * from tablename where condition)
Begin
  -- update query/insert query what ever you want
     insert into table name (column1,column2) values(value1,value2) 
End
 
Share this answer
 
v2

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