日期:2014-05-17  浏览次数:20761 次

datagridview实现更改的问题
具体代码如下
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Windows.Forms;

namespace student
{
    public partial class adslstucs : Form
    {
        SqlDataAdapter sqlda;
        DataSet sqlds;
        public adslstucs()
        {
            InitializeComponent();
        }

        private void adslstucs_Load(object sender, EventArgs e)
        {
            // TODO: 这行代码将数据加载到表“studentsysDataSet.student”中。您可以根据需要移动或删除它。
            this.studentTableAdapter.Fill(this.studentsysDataSet.student);
            SqlConnection conn = new SqlConnection("server=sam-pc;database=studentsys;uid=sa;pwd=sa");
            conn.Open();
            SqlDataAdapter sqlda;
            DataSet sqlds;
            sqlda = new SqlDataAdapter("select * from student", conn);
            sqlds = new DataSet();
            sqlda.Fill(sqlds, "student");
            dataGridView1.DataSource = sqlds.Tables["student"];
            SqlCommandBuilder sqlCmdBuilder = new SqlCommandBuilder(sqlda);

        }

        private void button1_Click(object sender, EventArgs e)
        {
            addstu Main = new addstu();
            Main.Show();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            destu Main = new destu();
            Main.Show();
        }

        private void button3_Click(object sender, EventArgs e)
        {
           
        &