使用c#进行数据库的增加删除修改查看数据
1、增加数据
2、删除数据
3、修改数据
public static void TestUpdate() //修改
{
//连接字符串
string strcon = "server=.;database=chuanzhiboke;Integrated Security=True";
//1、新建通道
SqlConnection conn = new SqlConnection();
conn.ConnectionString = strcon;
//2、准备新增sql命令
string strcommand = "update T_TempEmployee set Fname = 'leqing' where FName = 'Fotifa' ";
//3、新建命令对象,并前告诉它走那条路,做什么事情
SqlCommand cmd = new SqlCommand(strcommand, conn);
//4、打开通道
conn.Open();
//5、执行sql语句
int intres = -1;
intres = cmd.ExecuteNonQuery();
//6、关闭连接通道
conn.Close();
if (intres > 0)
{
Console.WriteLine("修改成功");
}
else
{
Console.WriteLine("修改失败");
}
}