请问执行后没有添加数据,哪里出错了,帮忙修改一下

using System.Data.SqlClient;

namespace WindowsFormsApplication7
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

    private void button1_Click(object sender, EventArgs e)
    {
        string Sql;

        string ConnectionString = "Server=(local);Integrated Security=SSPI;Database=student";
        SqlConnection conn = new SqlConnection(ConnectionString);
        conn.Open();
        MessageBox.Show("连接成功!");
        Sql="Select * from  学生";
        try
        {
            SqlDataAdapter adapter = new SqlDataAdapter(Sql, conn);
            DataTable datatable = new DataTable();
            adapter.Fill(datatable);
            Sql = "Insert Into 学生" + "Values('05','熊大','男','1995-5-12','2015-9-1','001')";
            SqlCommand cmd = new SqlCommand();
            cmd = new SqlCommand(Sql, conn);
             MessageBox.Show("添加成功");


            dataGridView1.DataSource = datatable;
        }
        catch (SqlException ex)
        {
            throw ex;
        }

    }
}

}

你数据库的表的字段定义了没有?需要table.Name = "熊大",等命令才能插入成功,不然数据库是没法自动帮你分配的

你的 SqlCommand没有执行啊,只是new了一个对象

在new SqlCommand之后,加上cmd.ExecuteNonQuery();

在new SqlComand之后加上cmd.ExecuteNonQuery();

你的 SqlCommand没有执行啊,只是new了一个对象