Page 1 of 1

Query.Fields[0]

Posted: Tue 23 Nov 2004 14:56
by jwillsey
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

Re: Query.Fields[0]

Posted: Wed 24 Nov 2004 10:27
by Ikar
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.

Re: Query.Fields[0]

Posted: Tue 30 Nov 2004 08:55
by Oleg
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
    ...