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 11 5143
Hi Elena, Dim intCount As Integer = dsID.Tables(0).Rows.Count Dim intActionIdentifier As Integer = dsID.Tables(0).Rows (intCount)("action_identifier").ToString intActionIdentifier = intActionIdentifier + 1
The index starts at 0
The count starts at 1
Therefore or it is Rows.Count - 1
or
intCount - 1
Cor
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... 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 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?
You don't fill the Dataset. Use the DataAdapter's Fill method.
--
Armin
Elena
I did not see the error Jan saw.
See my message there where 2 errors, the one which Jan saw and the one I
saw.
Cor
I fixed both errors. I now get an error with the
dataset... See my reply to Jan.
Thanks,
Elena -----Original Message----- Elena I did not see the error Jan saw.
See my message there where 2 errors, the one which Jan
saw and the one Isaw.
Cor
.
Elena
Will you try it like this
strsql = "Select * from Action where item_identifier = " &
Val(TextBox1.Text) & " order by action_identifier"
dim cmd as new OledbCommand(strsql, conn)
Dim daID As new OleDbDataAdapter(cmd)
Dim dsID As new DataSet
daID.Fill(dsID)
Dim intCount As Integer = dsID.Tables(0).Rows.Count-1
Dim intActionIdentifier As Integer = dsID.Tables(0).Rows
(intCount)("action_identifier").ToString
intActionIdentifier = intActionIdentifier + 1
I think this will work, I dont know for typos you know
Cor
"Elena" <el**********@yahoo.com> schrieb when i fill the dataset using this code: 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 daID.Fill(dsID, "Action")
I get the error at the fill line: An unhandled exception of type 'system.data.oledb.oledbexception' occurred in system.data.dll
What am I missing here?
You can catch the exception and examine it.
--
Armin http://www.plig.net/nnq/nquote.html http://www.netmeister.org/news/learn2quote.html
I still get the same error :-/
Elena -----Original Message----- Elena
Will you try it like this
strsql = "Select * from Action where item_identifier = " & Val(TextBox1.Text) & " order by action_identifier" dim cmd as new OledbCommand(strsql, conn) Dim daID As new OleDbDataAdapter(cmd) Dim dsID As new DataSet daID.Fill(dsID) Dim intCount As Integer = dsID.Tables(0).Rows.Count-1 Dim intActionIdentifier As Integer = dsID.Tables(0).Rows (intCount)("action_identifier").ToString intActionIdentifier = intActionIdentifier + 1
I think this will work, I dont know for typos you know
Cor .
Elena,
It is friday night here you know, I don't know if I stay long.
But try this, than we see the error better
\\\
Try
strsql = "Select * from Action where item_identifier = " &
Val(TextBox1.Text) & " order by action_identifier"
dim cmd as new OledbCommand(strsql, conn)
Dim daID As new OleDbDataAdapter(cmd)
Dim dsID As new DataSet
daID.Fill(dsID)
Dim intCount As Integer = dsID.Tables(0).Rows.Count-1
Dim intActionIdentifier As Integer = dsID.Tables(0).Rows
(intCount)("action_identifier").ToString
intActionIdentifier = intActionIdentifier + 1
Catch oledbExc As SqlException
MessageBox.Show(oledbExc.ToString, "", MessageBoxButtons.OK,
MessageBoxIcon.Error)
Catch ex As Exception
MessageBox.Show(ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
///
Cor
Hi Jan,
I had some problems with the SelectionChangeCommitted
I have made a sample in this newsgroup.
I think that it works when you fill the datasource as we did expected,
but when you fill it direct, it has strange behaviour,
Cor
Hi Elena
That is hard to say
Try to add en error handler like this
***********
Try
....Your code
Catch Ex as Exception
msgbox ex.Message
End Try
Than might give you a better idea of where to find the error
HTH
Jan
"Elena" <el**********@yahoo.com> skrev i en meddelelse
news:01****************************@phx.gbl... when i fill the dataset using this code: 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 daID.Fill(dsID, "Action")
I get the error at the fill line: An unhandled exception of type 'system.data.oledb.oledbexception' occurred in system.data.dll
What am I missing here?
-----Original Message----- 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... 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
. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Jim |
last post by:
I have a stored procedure that queries a sql server database and returns the
multiple data tables ( 7 to be precise) these tables are the results of many
joins.
When I use the...
|
by: Nedu N |
last post by:
Hi All,
I am facing problem in copying content of table from a untyped dataset into
to a table inside the typed dataset. I wanted to copy the data into typed
dataset in order to ease the further...
|
by: Johann Blake |
last post by:
I have a dataset that contains a parent table and a child table. A
DataRelation exists between the two. I was under the impression from
reading the VS docs that when I filled the parent table, the...
|
by: Thanks |
last post by:
I have a routine that is called on Page_Init. It retrieves folder records
from a database which I display as Link Buttons in a table cell. I set the
table cell's bgcolor to a default color (say...
|
by: ASP Yaboh |
last post by:
I have an ArrayList of data gathered from a database. I want to create a web
page from this data by creating a <table>, each cell in each row displays the
appropriate data. One of those cells in...
|
by: EMW |
last post by:
Hi,
I managed to create a SQL server database and a table in it. The table is
empty and that brings me to my next chalenge:
How can I get the info in the table in the dataset to go in an empty...
|
by: PAUL |
last post by:
Hello,
I have 2 tables with a relationship set up in the dataset with vb
..net. I add a new record to the parent table then edit an existing child
record to have the new parent ID. However when I...
|
by: glenn |
last post by:
Hi folks,
I am trying to page through a portion of the data in a table and therefore I
think I need to use Custom Paging.
.... but, I am wondering if I can pass a dataset that was obtained...
|
by: samoore33 |
last post by:
I want to list all of the items in a dataset in a textbox. The dataset
has multiple tables. When I try to use the code below, even though I
dim myState as the DataTable("state"). It still looks for...
|
by: DrSnap |
last post by:
Hi,
Admitted I am a newbie to Oracle (databases in general) but now Ive
installed the Oracle DB v.10g and the ODAC development tools for
Microsoft Visual Studio 2005.
So, now i've found out,...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |