using PreSqlData.DataProcess;
2010-03-20 17:33
190 查看
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;
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 = sc.SelTable(); //获取DataGridView的数据源
dataGridView1.DataSource = ds.Tables[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 = con.CreateCommand();
cmd.CommandText = "select * from Table_gongzi";
SqlDataAdapter da = new SqlDataAdapter(cmd);
SqlCommandBuilder cb = new SqlCommandBuilder(da);//使用SqlCommandBuilder的话,首先要求你的表有主键
//然后他会根据你提供的查询语句,生成插入,修改,删除语句
//再根据DataTable对应的数据行状态来调用对应的语句执行数据库操作
da.Update(ds.Tables[0]);
dataGridView1.Update();
}
private void button2_Click(object sender, EventArgs e)
{
DataRowView drv = dataGridView1.SelectedRows[0].DataBoundItem as DataRowView;
drv.Delete();
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 = con.CreateCommand();
// cmd.CommandText = "select * from Table_gongzi";
SqlDataAdapter da = new SqlDataAdapter(cmd);
SqlCommandBuilder cb = new SqlCommandBuilder(da);//必须new SqlCommandBuilder 否则da.Update报错
da.Update(ds.Tables[0]);
dataGridView1.Update();
}
}
}
转载声明: 本文转自 http://blog.csdn.net/shanzhaikaifa/archive/2009/08/13/4443931.aspx
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;
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 = sc.SelTable(); //获取DataGridView的数据源
dataGridView1.DataSource = ds.Tables[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 = con.CreateCommand();
cmd.CommandText = "select * from Table_gongzi";
SqlDataAdapter da = new SqlDataAdapter(cmd);
SqlCommandBuilder cb = new SqlCommandBuilder(da);//使用SqlCommandBuilder的话,首先要求你的表有主键
//然后他会根据你提供的查询语句,生成插入,修改,删除语句
//再根据DataTable对应的数据行状态来调用对应的语句执行数据库操作
da.Update(ds.Tables[0]);
dataGridView1.Update();
}
private void button2_Click(object sender, EventArgs e)
{
DataRowView drv = dataGridView1.SelectedRows[0].DataBoundItem as DataRowView;
drv.Delete();
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 = con.CreateCommand();
// cmd.CommandText = "select * from Table_gongzi";
SqlDataAdapter da = new SqlDataAdapter(cmd);
SqlCommandBuilder cb = new SqlCommandBuilder(da);//必须new SqlCommandBuilder 否则da.Update报错
da.Update(ds.Tables[0]);
dataGridView1.Update();
}
}
}
转载声明: 本文转自 http://blog.csdn.net/shanzhaikaifa/archive/2009/08/13/4443931.aspx
相关文章推荐
- using PreSqlData.DataProcess;
- using PreSqlData.DataProcess;
- using PreSqlData.DataProcess;
- using PreSqlData.DataProcess;
- media foundation (Using the Source Reader to Process Media Data)
- MS Bigdata HDInsight -Process, analyze, and gain new insights from big data using the power of Apache Hadoop
- Using the Adobe AIR 2 NativeProcess API to create a screen recorder
- Putting Data and Business Process Integration in Context @ JDJ
- DataContractJsonSerializer 没有using 类库找不到
- Using Google Visualization API with own data soure(转http://www.jansipke.nl/using-google-visualization-api-with-own-data-source)
- 17.1.1.5 Creating a Data Snapshot Using mysqldump
- Cousera-Using python to access web data(第2~4周笔记)
- Using C# for Inserting CLOB data in Oracle
- 使用SqlConnection连接SQL server2008 R2数据库的语句using System.Data.SqlClient;using System.Data.SqlClient;
- Using GridLink Data Sources in WebLogic 10.3.4
- E: Unable to lock the administration directory (/var/lib/dpkg/), is another process using it?
- Using Process Infection to Bypass Firewalls
- 6: Csvcut | Csvstat( Data Cleaning and Exploration Using Csvkit)
- Use External Storage Process Big Data(1)
- Read and Write compressed data to a binary file using ASP.NET