使用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怎么替换
  • 热门搜索
    鳗鱼干怎么做好吃 为什么老是放屁 牙疼怎么办一招教你3秒治牙疼 this怎么读 工作单位怎么填 biang字怎么写 绮怎么读 孕妇乌鸡汤的做法 痛经怎么办 仙人掌为什么长刺