⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 studentid.cs

📁 同学学习时的即性之作,电话本仅供大家作为参考.
💻 CS
字号:
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Windows.Forms;

namespace 电话本
{
    class studentID
    {
        private int id;
        private string name;
        SqlConnection conn;
        SqlCommand comm;
        public int ID
        {
            get { return id; }
            set { id = value; }
        }
        public string Name
        {
            get { return name; }
            set { name = value; }
        }
        public studentID()
        {
            conn = new SqlConnection("server=张辉\\SQLEXPRESS;integrated security=SSPI;database=张辉");
        }
        public void add()
        {
            conn.Open();
            SqlTransaction objTraction = conn.BeginTransaction();
            comm = new SqlCommand();
            comm.Transaction = objTraction;

            comm.CommandText = "insert into studentID values(" + this.id + ",'" + this.name + "')" + "insert into studentID values(6,'xiaoming')";
            comm.Connection = conn;
            int x=comm.ExecuteNonQuery();
            //if (x ==2)
            //{
             objTraction.Commit();
            //}
            //else
            //{
            //    objTraction.Rollback();
            //}
            
            conn.Close();
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -