Count record.

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for MySQL
Post Reply
jwillsey

Query.Fields[0]

Post by jwillsey » Tue 23 Nov 2004 14:56

I'm having a similar problem, but when I try to read Query.Fields[0], I get the following error message:

An unhandled exception of type 'System.IndexOutOfRangeException' occurred in system.data.dll

Additional information: Index was outside the bounds of the array.


Here's a sample of my code:

Dim MyCommand As New OleDb.OleDbCommand
MyCommand.Connection = MyConnection
MyCommand.CommandText = "select count(*) from employee"

Dim MyDataReader As OleDb.OleDbDataReader
MyDataReader = MyCommand.ExecuteReader

MyDataReader.Read()
If Me.C1tbID.Tag = MyDataReader.GetValue(0) Then

Ikar
Posts: 1693
Joined: Thu 28 Oct 2004 13:56

Re: Query.Fields[0]

Post by Ikar » Wed 24 Nov 2004 10:27

jwillsey wrote:I'm having a similar problem, but when I try to read Query.Fields[0], I get the following error message:
A sample of your code doesn't concern MyDAC. Suppose, you should ask your question in relating to MySQLDirect .NET.

Oleg
Devart Team
Posts: 264
Joined: Thu 28 Oct 2004 13:56

Re: Query.Fields[0]

Post by Oleg » Tue 30 Nov 2004 08:55

Your example doesn't concern MySQLDirect .NET, as you use .NET Framework OleDB provider.
The error might happen at you by the reason that your query doesn't return records.
Change your code in the following way:

Code: Select all

If MyDataReader.Read() Then
  If Me.C1tbID.Tag = MyDataReader.GetValue(0) Then
    ...

Post Reply