更新数据库 [英] Updating the databse
本文介绍了更新数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想用用户输入更新我的数据库,我已经这样写了插入内容:
I wanna to Update my data base with user input , I have written the insert like this :
SqlConnection con = new SqlConnection();
con.ConnectionString= ConfigurationManager.ConnectionStrings["MyConnectionString"].ConnectionString;
SqlCommand com = new SqlCommand();
com.Connection = con;
com.CommandText = "Insert into tbl_Users (UserName,Passwrd,Email) values (@input1,@input2,@input3)";
com.Parameters.AddWithValue("Input1", txtU.Text);
com.Parameters.AddWithValue("input2", txtP.Text);
com.Parameters.AddWithValue("input3", txtE.Text);
try
{
con.Open();
com.ExecuteNonQuery();
}
catch (SqlException ex)
{
Response.Write(ex.Message);
}
finally
{
con.Close();
}
现在,如何编写像这样的Update和Delete ???
Now , How can I write Update and delete like this ???
推荐答案
您将获得使用参数的奖励积分.辛苦了
SQL更新 [ ^ ]
SQL删除 [ ^ ]
You get bonus points for using parameters. Good work.
SQL Update[^]
SQL Delete[^]
这篇关于更新数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文