设为首页 加入收藏

TOP

在vs.net bate 2中的ado.net简单编程(傻瓜版)(二)
2014-11-23 20:25:17 来源: 作者: 【 】 浏览:15
Tags:vs.net bate ado.net 简单 编程 傻瓜
Click += new System.EventHandler(this.Button1_Click);
//
// sqlConnection1
//
this.sqlConnection1.ConnectionString = "data source=(local);initial catalog=xr;integrated security=SSPI;persist security " +
"info=False;workstation id=XURUI;packet size=4096";
//
// dataSet11
//
this.dataSet11.DataSetName = "DataSet1";
this.dataSet11.Locale = new System.Globalization.CultureInfo("zh-CN");
this.dataSet11.Namespace = "http://www.tempuri.org/DataSet1.xsd";
//
// sqlInsertCommand1
//
this.sqlInsertCommand1.CommandText = "INSERT INTO store(zipcode, area, name) VALUES (@zipcode, @area, @name); SELECT zi" +
"pcode, area, name FROM store";
this.sqlInsertCommand1.Connection = this.sqlConnection1;
this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@zipcode", System.Data.SqlDbType.Char, 10, System.Data.ParameterDirection.Input, true, ((System.Byte)(0)), ((System.Byte)(0)), "zipcode", System.Data.DataRowVersion.Current, null));
this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@area", System.Data.SqlDbType.Char, 10, System.Data.ParameterDirection.Input, true, ((System.Byte)(0)), ((System.Byte)(0)), "area", System.Data.DataRowVersion.Current, null));
this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@name", System.Data.SqlDbType.Char, 10, System.Data.ParameterDirection.Input, true, ((System.Byte)(0)), ((System.Byte)(0)), "name", System.Data.DataRowVersion.Current, null));
//
// sqlSelectCommand1
//
this.sqlSelectCommand1.CommandText = "SELECT zipcode, area, name FROM store ";
this.sqlSelectCommand1.Connection = this.sqlConnection1;
//
// sqlDataAdapter1
//
this.sqlDataAdapter1.InsertCommand = this.sqlInsertCommand1;
this.sqlDataAdapter1.SelectCommand = this.sqlSelectCommand1;
this.sqlDataAdapter1.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] {
new System.Data.Common.DataTableMapping("Table", "store", new System.Data.Common.DataColumnMapping[] {....................................

...........................

你可以根据自己的需要生成数据集。

加入新列你可以这样做:

DataTable dt;//定义一个表(废话)
dt=dataSet11.Tables ["你的表"];//给表付值

DataRow dr;
dr=d

首页 上一页 1 2 下一页 尾页 2/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇Blackcomb 和Windows.NET 现身? 下一篇在 Windows 2000 中如何配置 IPSe..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: