如何创建用户定义的数据表 [英] How to Create User Defined Data Table

查看:62
本文介绍了如何创建用户定义的数据表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的所有人,

我是编程新手,我想知道如何在ASP.Net.2010中创建用户定义的数据表


请使用Same.

Dear All,

I am New to Programming and I want to know About How to Create user defined Data Table In ASP.Net.2010


Please help me with the Same.

推荐答案

.如果我很了解,您想以编程方式创建DataTable:

这是实现该目标的一种方法:

If I understood well you want to create a DataTable programmatically:

This is a way to achieve that:

DataTable dt = new DataTable();

DataColumn column = new DataColumn();
column.ColumnName = "ID";
column.AllowDBNull = false;
column.DataType = typeof(int);
column.AutoIncrement = true;
column.AutoIncrementSeed = 1000;
column.AutoIncrementStep = 1;

dt.Columns.Add(column);
dt.Columns.Add("Name", typeof(string));
dt.PrimaryKey = new DataColumn[] { column };

DataRow row = dt.NewRow();
row["Name"] = "Mario";
dt.Rows.Add(row);



干杯



Cheers


这篇关于如何创建用户定义的数据表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆