Scalar

态度决定一切,正能量走起!

导航

SqlCommandBuilder (供自己查阅)

代码
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 WorkFlow
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
DataSet ds;
SqlDataAdapter myAdapter;
SqlCommandBuilder myCommandBuilder;
private void Form1_Load(object sender, EventArgs e)
{
string str = "data source=(local);persist security info=false;initial catalog=WorkFlow;integrated security=true";
SqlConnection con
= new SqlConnection(str);
ds
= new DataSet();

con.Open();
myAdapter
= new SqlDataAdapter("select * from T_user",con); 
myCommandBuilder
= new SqlCommandBuilder(myAdapter);
myAdapter.InsertCommand
= myCommandBuilder .GetInsertCommand();
myAdapter.UpdateCommand
= myCommandBuilder.GetUpdateCommand();
myAdapter.DeleteCommand
= myCommandBuilder .GetDeleteCommand();
myAdapter.Fill(ds);
ds.Tables[
0].Rows[0][1] = "123";
dataGridView1.DataSource
= ds.Tables[0];
myAdapter.Update(ds);
con.Close();
}
}

posted on 2011-10-16 09:42  Scalar  阅读(107)  评论(0)    收藏  举报