using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace WindowsApplication1
{
    public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
        }

        private void Form2_Load(object sender, EventArgs e)
        {
            
        }

        private void button1_Click(object sender, EventArgs e)
        {
            SqlConnection conn = new SqlConnection();
            conn.ConnectionString = "Data Source=(local);Initial Catalog=school;User ID=sa";
            conn.Open();

            SqlTransaction sqltran = conn.BeginTransaction();
            string sqlstring = "insert into student(sno,sname) values(3390220,'张三')";
            SqlCommand comm = new SqlCommand(sqlstring, conn);
            comm.Transaction = sqltran;
            int p = comm.ExecuteNonQuery();
            sqltran.Commit();
            comm.Dispose();
            comm.Clone();
            conn.Dispose();
            conn.Close();
        }
    }
}