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