C# ExecuteNonQuery用法

2021-05-13 14:28

阅读:759

标签:string   rgs   cli   open   code   using   cmd   ext   window   

using System;
using System.Data;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace UseExecuteNonQuery
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        SqlConnection conn;
        private void button1_Click(object sender, EventArgs e)
        {
            conn = new SqlConnection("server=.;database=db_12;uid=sa;pwd=sa");
            conn.Open();
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = conn;
            cmd.CommandText = "update tb_command set 奖金=503 where 性别=‘女‘";
            cmd.CommandType = CommandType.Text;
            int i = Convert.ToInt32(cmd.ExecuteNonQuery());//返回受影响的函数
            label2.Text = "共有" + i.ToString() + "名女员工获得奖金";
        }
    }
}

 

C# ExecuteNonQuery用法

标签:string   rgs   cli   open   code   using   cmd   ext   window   

原文地址:http://www.cnblogs.com/stringAdmin/p/7543619.html


评论


亲,登录后才可以留言!