数据库问题:oDataSet.Table[0].Rows[0].ItemArray[8]中ItemArray[8]表示什么值??

我给TextBox控件副值代码:this.txtLoginName.Text=oDataSet.Table[0].Rows[0].ItemArray[8]照理说:是第一行... 我给TextBox控件副值代码:
this.txtLoginName.Text=oDataSet.Table[0].Rows[0].ItemArray[8]
照理说:是第一行的第9个字段值~
可是结果是错误的~~~
请指教一下,小弟不胜感激!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
展开
 我来答
kadxm
2006-09-25 · TA获得超过705个赞
知道小有建树答主
回答量:829
采纳率:0%
帮助的人:0
展开全部
通过一个数组来获取或设置此行的所有值。

下面的示例显示如何使用 ItemArray 属性获取或设置值。

Visual Basic 复制代码
Private Sub CreateRowsWithItemArray()
' Make a DataTable using the function below.
Dim dt As DataTable = MakeTableWithAutoIncrement()
Dim relation As DataRow

' Declare the array variable.
Dim rowArray(1) As Object

' Create 10 new rows and add to DataRowCollection.
Dim i As Integer
For i = 0 to 9
rowArray(0) = DBNull.Value
rowArray(1)= "item " & i.ToString()
relation = dt.NewRow()
relation.ItemArray = rowArray
dt.Rows.Add(relation)
Next
PrintTable(dt)
End Sub

Private Function MakeTableWithAutoIncrement() As DataTable
' Make a table with one AutoIncrement column.
Dim table As DataTable = New DataTable("table")
Dim idColumn As DataColumn = New DataColumn("id", _
Type.GetType("System.Int32"))
idColumn.AutoIncrement = True
idColumn.AutoIncrementSeed = 10
table.Columns.Add (idColumn)

Dim firstNameColumn As DataColumn = New DataColumn( _
"Item", Type.GetType("System.String"))
table.Columns.Add(firstNameColumn)
MakeTableWithAutoIncrement = table
End Function

Private Sub PrintTable(table As DataTable)
Dim row As DataRow
Dim column As DataColumn
For Each row in table.Rows
For Each column in table.Columns
Console.WriteLine(row(column))
Next
Next
End Sub

C# 复制代码
private void CreateRowsWithItemArray()
{
// Make a DataTable using the function below.
DataTable dt = MakeTableWithAutoIncrement();
DataRow relation;
// Declare the array variable.
object [] rowArray = new object[2];
// Create 10 new rows and add to DataRowCollection.
for(int i = 0; i <10; i++)
{
rowArray[0]=null;
rowArray[1]= "item " + i;
relation = dt.NewRow();
relation.ItemArray = rowArray;
dt.Rows.Add(relation);
}
PrintTable(dt);
}

private DataTable MakeTableWithAutoIncrement()
{
// Make a table with one AutoIncrement column.
DataTable table = new DataTable("table");
DataColumn idColumn = new DataColumn("id",
Type.GetType("System.Int32"));
idColumn.AutoIncrement = true;
idColumn.AutoIncrementSeed = 10;
table.Columns.Add(idColumn);

DataColumn firstNameColumn = new DataColumn("Item",
Type.GetType("System.String"));
table.Columns.Add(firstNameColumn);
return table;
}

private void PrintTable(DataTable table)
{
foreach(DataRow row in table.Rows)
{
foreach(DataColumn column in table.Columns)
{
Console.WriteLine(row[column]);
}
}
}
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式