Insert Data Using SqlCommandBuilder
2006-02-21 10:08
465 查看
using System;
using System.Data;
using System.Data.SqlClient;
namespace Client.Chapter_13___ADO.NET
{
public class InsertingDataUsingCommandBuilder
{
static void Main(string[] args)
{
SqlConnection MyConnection = new SqlConnection(@"Data Source=(local); Initial Catalog = CaseManager; Integrated Security=true");
SqlDataAdapter MyDataAdapter = new SqlDataAdapter("SELECT ID, Contact, Email FROM Test", MyConnection);
SqlCommandBuilder MyCmd = new SqlCommandBuilder(MyDataAdapter);
DataSet MyDataSet = new DataSet();
MyDataAdapter.Fill(MyDataSet);
DataRow MyRow = MyDataSet.Tables[0].NewRow();
MyRow["ID"] = 200;
MyRow["Contact"] = "Greg";
MyRow["Email"] = "MacBeth";
MyDataSet.Tables[0].Rows.Add(MyRow);
MyDataAdapter.Update(MyDataSet);
}
}
}
using System.Data;
using System.Data.SqlClient;
namespace Client.Chapter_13___ADO.NET
{
public class InsertingDataUsingCommandBuilder
{
static void Main(string[] args)
{
SqlConnection MyConnection = new SqlConnection(@"Data Source=(local); Initial Catalog = CaseManager; Integrated Security=true");
SqlDataAdapter MyDataAdapter = new SqlDataAdapter("SELECT ID, Contact, Email FROM Test", MyConnection);
SqlCommandBuilder MyCmd = new SqlCommandBuilder(MyDataAdapter);
DataSet MyDataSet = new DataSet();
MyDataAdapter.Fill(MyDataSet);
DataRow MyRow = MyDataSet.Tables[0].NewRow();
MyRow["ID"] = 200;
MyRow["Contact"] = "Greg";
MyRow["Email"] = "MacBeth";
MyDataSet.Tables[0].Rows.Add(MyRow);
MyDataAdapter.Update(MyDataSet);
}
}
}
相关文章推荐
- Deleting Data Using SqlCommandBuilder
- SqlDataAdapter可以用SqlCommandBuilder 实现批量更新
- SqlDataAdapter.Update()方法与SqlCommandBuilder
- SqlDataAdapter和SqlCommandBuilder添加数据
- SqlDataAdapter和SqlCommandBuilder删除数据
- SqlDataAdapter和SqlCommandBuilder删除数据
- SqlDataAdapter.Update()方法与SqlCommandBuilder(转)
- 我想操作的是利用SqlDataAdapter的几个Command属性(InsertCommand,UpdateCommand,DeleteCommand)来更新数据库
- SqlDataAdapter.Update()方法与SqlCommandBuilder
- SqlDataAdapter SqlCommandBuilder update 批量更新
- SqlDataAdapter.Update()方法与SqlCommandBuilder
- SqlCommandBuilder在用SqlDataReader更新数据源时的作用
- SqlcommandBuilder Sqlcommand sqldataAdapter DataSet DataTable
- SqlDataAdapter和SqlCommandBuilder添加数据
- [SQL Server][FILESTREAM] -- Using INSERT, UPDATE and DELETE to manage SQL Server FILESTREAM Data
- Use SqlDataAdapter to update database, but SqlCommandBuilder required
- 找不到类型或命名空间名称 SqlDataAdapter (是否缺少 using 指令或程序集引用?)
- that-annoying-insert-problem-getting-data-into-the-db-using-dapper
- SqlDataAdapter.UpdateCommand 属性(极易出错的地方)(转自:http://blog.csdn.net/tsapi/archive/2011/03/29/6286654.aspx)
- asp.net中使用sqlcommandbuilder (转)