English 中文(简体)
页: 1
原标题:datacoloumn in asp.net

首先,我想在数据集中增加一个数据库栏,然后在数据表中增加数据。 请指导我;

SqlDataAdapter d2 = new SqlDataAdapter("select MARK_PARTA from  exam_cyctstmarkdet",con);
DataColumn c = new DataColumn();                      
c.ColumnName = "parta";
c.DataType = System.Type.GetType("System.Int32");
问题回答

您再次失踪

DataTable DT = new DataTable;
d2.Fill(DT);
DT.Columns.Add(c);

?

如果你希望建立一个数据表,并增加自己的栏目,你可以尝试

DataTable dt = new DataTable("MyTable");
DataColumn col = dt.Columns.Add("parta", typeof(int));

如果你计划在某些地方使用该栏,那么你只得提及该栏,否则你可以尝试。

DataTable dt = new DataTable("MyTable");
dt.Columns.Add("parta", typeof(int));

我建议你使用<代码>SqlDataAdapter,以填满<代码>DataSet,其中将包含一个<代码> 可。 我假定你想在本《<条码>中添加新的一栏。

这里是怎样做的:

SqlDataAdapter d2 = new SqlDataAdapter("select MARK_PARTA from  exam_cyctstmarkdet",con);
DataSet dst = new DataSet();
d2.Fill(dst); // now you have a populated DataSet containing a DataTable
DataTable dt = dst.Tables[0]; // I created this variable for clarity; you don t really need it

DataColumn c = new DataColumn();                      
c.ColumnName = "parta";
c.DataType = System.Type.GetType("System.Int32");

dt.Add(c);

添加<代码>Column至>DataTable后,Column将空。

你可以在法典中填满。





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签