2024年5月2日发(作者:)

using System;

using c;

using entModel;

using ;

using g;

using ;

using ;

using ;

using ent;

namespace AllSaveGrid

{

public partial class Form1 : Form

{

DataSet ds = new DataSet();

public Form1()

{

InitializeComponent();

GridControl_Bind();

}

public void GridControl_Bind()

{

SqlClass sc = new SqlClass();

//DataSet ds = new DataSet();

ds = le(); //获取DataGridView的数

据源

urce = [0];

}

private void button1_Click(object sender, EventArgs e)

{

SqlConnection con = new

SqlConnection("server='localhost';database='Work';user='sa';password='123'");

SqlCommand cmd = new SqlCommand();

cmd = Command();

dText = "select * from Table_gongzi";

SqlDataAdapter da = new SqlDataAdapter(cmd);

SqlCommandBuilder cb = new SqlCommandBuilder(da);//使用

SqlCommandBuilder的话,首先要求你的表有主键

//然后他会根据你提

供的查询语句,生成插入,修改,删除语句

//再根据DataTable对

应的数据行状态来调用对应的语句执行数据库操作

([0]);

();

}

private void button2_Click(object sender, EventArgs e)

{

DataRowView drv = edRows[0].DataBoundItem as

DataRowView;

();

SqlConnection con=new

SqlConnection("server='localhost';database='Work';user='sa';password='123'");

SqlCommand cmd = new SqlCommand("select * from Table_gongzi", con);

// SqlCommand cmd = new SqlCommand();

// cmd = Command();

// dText = "select * from Table_gongzi";

SqlDataAdapter da = new SqlDataAdapter(cmd);

SqlCommandBuilder cb = new SqlCommandBuilder(da);//必须new

SqlCommandBuilder 否则报错

([0]);

();

}

}

}