使用c#进行数据库的增加删除修改查看数据

 时间:2026-02-14 18:24:21

1、增加数据

使用c#进行数据库的增加删除修改查看数据

2、删除数据

使用c#进行数据库的增加删除修改查看数据

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("修改失败");

            }

        }

使用c#进行数据库的增加删除修改查看数据

  • jquery实现鼠标放在文字上改变文字颜色
  • python如何创建excel表格
  • html里面背景图片怎么设置调整
  • Python 整数的格式打印输出/print的使用
  • webstorm怎么替换
  • 热门搜索
    车载电话怎么用 汗臭怎么办 怎么治疗过敏性鼻炎 左胸疼是怎么回事 珍珠鸡怎么分公母 火狐浏览器怎么样 痤疮怎么去 络腮胡子怎么去除 前锋热水器怎么样 会计怎么样