ADO.NET修改数据
2021-06-30 12:06
标签:16px too net int microsoft mil sof new com ADO.NET修改数据 标签:16px too net int microsoft mil sof new com 原文地址:http://www.cnblogs.com/wcl2017/p/7136414.htmlConsole.Write("请输入您想改的内容:");
string ucode = Console.ReadLine();
string sql = "server=.;database=Data0504;user=sa;pwd=123";
SqlConnection conn = new SqlConnection(sql);
SqlCommand cmd = conn.CreateCommand();
cmd.CommandText = "update Users set NickName =‘" + ucode + "‘ where NickName=‘李四‘";
conn.Open();
int count = cmd.ExecuteNonQuery();
conn.Close();
if (count > 0)
{
Console.WriteLine("更改成功");
}
else
{
Console.WriteLine("更改失败!");
}
Console.ReadLine();