1. 程式人生 > >C# ExecuteNonQuery用法

C# ExecuteNonQuery用法

clas man pub class int32 bject code tex oid

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用法