Count record.

Query.Fields[0]

Postby 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
jwillsey
 

Re: Query.Fields[0]

Postby 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.
Ikar
 
Posts: 1693
Joined: Thu 28 Oct 2004 13:56

Re: Query.Fields[0]

Postby 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
    ...
Oleg
Devart Team
 
Posts: 264
Joined: Thu 28 Oct 2004 13:56


Return to dotConnect for MySQL