数据集中的表格? [英] Table in Dataset?
问题描述
我想从表格的最后一行得到一个数字。
当我到达代码行来计算时,我得到一个
错误:
system.data.dll中出现未处理的
类型''System.IndexOutOfRangeException'异常br />
附加信息:找不到表0
代码如下:
''获取新的商品编号
strsql ="从Action中选择*,其中item_identifier =" &
Val(TextBox1.Text)& " order by action_identifier"
''创建数据适配器对象
Dim daID作为OleDbDataAdapter =新OleDbDataAdapter
(strsql,conn)
''创建数据集对象并使用数据填充数据
adapter'的填充方法
Dim dsID As DataSet = New DataSet
Dim intCount As Integer = dsID.Tables(0).Rows.Count
Dim intActionIdentifier As Integer = dsID.Tables(0).Rows
(intCount) (" action_identifier")。ToString
intActionIdentifier = intActionIdentifier + 1
有什么我想念的吗?
提前致谢!
Elena
I am trying to get a number from the last row in a table.
When I get to the line of code to get the count, I get an
error:
An Unhandled exception of
type ''System.IndexOutOfRangeException'' occured in
system.data.dll
Additional Information: Cannot find table 0
The code is below:
''get a new item number
strsql = "Select * from Action where item_identifier = " &
Val(TextBox1.Text) & " order by action_identifier"
'' Create data adapter object
Dim daID As OleDbDataAdapter = New OleDbDataAdapter
(strsql, conn)
'' Create a dataset object and fill with data using data
adapter''s Fill method
Dim dsID As DataSet = New DataSet
Dim intCount As Integer = dsID.Tables(0).Rows.Count
Dim intActionIdentifier As Integer = dsID.Tables(0).Rows
(intCount)("action_identifier").ToString
intActionIdentifier = intActionIdentifier + 1
Is there something I am missing?
Thanks in advance!
Elena
推荐答案
嗨Elena,
Dim intCount As Integer = dsID.Tables(0).Rows.Count
Dim intActionIdentifier As Integer = dsID.Tables(0).Rows
(intCount)(" action_identifier")。ToString
intActionIdentifier = intActionIdentifi er + 1
Dim intCount As Integer = dsID.Tables(0).Rows.Count
Dim intActionIdentifier As Integer = dsID.Tables(0).Rows
(intCount)("action_identifier").ToString
intActionIdentifier = intActionIdentifier + 1
索引从0开始
计数从1开始
因此或者它是Rows.Count - 1
或
intCount - 1
Cor
The index starts at 0
The count starts at 1
Therefore or it is Rows.Count - 1
or
intCount - 1
Cor
嗨Elena
据我所见,你没有填写数据集。
你缺乏:
Hi Elena
As far as I can see you don''t fill the dataset.
You lack:
Dim dsID As DataSet = New DataSet
daID.Fill(dsID)Dim intCount As Integer = dsID.Tables(0).Rows.Count
HTH
Jan
" Elena" < EL ********** @ yahoo.com> skrev i en meddelelse
news:0b **************************** @ phx.gbl ...我试图从表格的最后一行得到一个数字。
当我到达代码行来计算时,我得到一个
错误:
类型'System.IndexOutOfRangeException'未处理的异常发生在
system.data.dll
附加信息:找不到表0
代码如下:
''获得一个新的项目编号
strsql ="从Action中选择*,其中item_identifier =" &
Val(TextBox1.Text)& " order by action_identifier"
''创建数据适配器对象
Dim daID As OleDbDataAdapter = New OleDbDataAdapter
(strsql,conn)
''创建数据集对象并使用数据填充数据
适配器的填充方法
Dim dsID As DataSet = New DataSet
Dim intCount As Integer = dsID.Tables(0).Rows.Count
Dim intActionIdentifier As Integer = dsID .Tables(0)。行
(intCount)(" action_identifier")。ToString
intActionIdentifier = intActionIdentifier + 1
我有什么遗漏吗?
提前致谢!
Elena
Dim dsID As DataSet = New DataSet daID.Fill(dsID) Dim intCount As Integer = dsID.Tables(0).Rows.Count
HTH
Jan
"Elena" <el**********@yahoo.com> skrev i en meddelelse
news:0b****************************@phx.gbl... I am trying to get a number from the last row in a table.
When I get to the line of code to get the count, I get an
error:
An Unhandled exception of
type ''System.IndexOutOfRangeException'' occured in
system.data.dll
Additional Information: Cannot find table 0
The code is below:
''get a new item number
strsql = "Select * from Action where item_identifier = " &
Val(TextBox1.Text) & " order by action_identifier"
'' Create data adapter object
Dim daID As OleDbDataAdapter = New OleDbDataAdapter
(strsql, conn)
'' Create a dataset object and fill with data using data
adapter''s Fill method
Dim dsID As DataSet = New DataSet
Dim intCount As Integer = dsID.Tables(0).Rows.Count
Dim intActionIdentifier As Integer = dsID.Tables(0).Rows
(intCount)("action_identifier").ToString
intActionIdentifier = intActionIdentifier + 1
Is there something I am missing?
Thanks in advance!
Elena
" Elena" < EL ********** @ yahoo.com> schrieb
"Elena" <el**********@yahoo.com> schrieb
我试图从表格的最后一行得到一个数字。
当我到达代码行来计算时,我得到一个
错误:
类型'System.IndexOutOfRangeException'的未处理异常发生在
system.data.dll
附加信息:找不到表0
代码如下:
''得到一个新的项目编号
strsql ="从Action中选择*,其中item_identifier =" &
Val(TextBox1.Text)& " order by action_identifier"
''创建数据适配器对象
Dim daID As OleDbDataAdapter = New OleDbDataAdapter
(strsql,conn)
''创建数据集对象并使用数据填充数据
适配器的填充方法
Dim dsID As DataSet = New DataSet
Dim intCount As Integer = dsID.Tables(0).Rows.Count
Dim intActionIdentifier As Integer = dsID .Tables(0)。行
(intCount)(" action_identifier")。ToString
intActionIdentifier = intActionIdentifier + 1
我有什么遗漏?
I am trying to get a number from the last row in a table.
When I get to the line of code to get the count, I get an
error:
An Unhandled exception of
type ''System.IndexOutOfRangeException'' occured in
system.data.dll
Additional Information: Cannot find table 0
The code is below:
''get a new item number
strsql = "Select * from Action where item_identifier = " &
Val(TextBox1.Text) & " order by action_identifier"
'' Create data adapter object
Dim daID As OleDbDataAdapter = New OleDbDataAdapter
(strsql, conn)
'' Create a dataset object and fill with data using data
adapter''s Fill method
Dim dsID As DataSet = New DataSet
Dim intCount As Integer = dsID.Tables(0).Rows.Count
Dim intActionIdentifier As Integer = dsID.Tables(0).Rows
(intCount)("action_identifier").ToString
intActionIdentifier = intActionIdentifier + 1
Is there something I am missing?
你没有填写数据集。使用DataAdapter的填充方法。
-
Armin
You don''t fill the Dataset. Use the DataAdapter''s Fill method.
--
Armin
这篇关于数据集中的表格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!