使用c#进行数据库的增加删除修改查看数据
1、增加数据
2、删除数据
3、修改数据public stat坡纠课柩ic 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("修改失败"); } }
声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
阅读量:34
阅读量:64
阅读量:91
阅读量:75
阅读量:43