Have you tried reading the documentation?
ExecuteNonQuery (as its name suggest, not meant to query data) returns the
number of records affected by the query. Since this is not an
Update/Delete/Insert statement, it does not affect any records - it is a
SELECT statement. SELECT statements dont' affect any records.
You are looking for ExecuteScalar.
"The VanDerbeck Group" <Th****************@discussions.microsoft.com> wrote
in message news:A4**********************************@microsof t.com...
Sorry,
I'm trying to set ...
ProgressBar1.Maximum = recordcount.ExecuteNonQuery()
It returns -1 although I know that the database is populated with 40K+
records.
"Marina" wrote:
You are not showing any place where you are actually executing the query.
"The VanDerbeck Group" <Th****************@discussions.microsoft.com>
wrote
in message news:F1**********************************@microsof t.com... >I have a odbc connection I am making to a xbase .dbf file and want to
> determine the number of records in the file. THe following code keeps
> returning -1 to me???
>
> Any Ideas?
>
>
> CODE:
>
> Dim oODBCConnection As OdbcConnection
> Dim sConnString As String = "Driver={Microsoft dBase Driver
> (*.dbf)};DBQ=f:\105\dsd\dbfs\"
>
> Dim mystring As String = "Select * FROM Product"
> Dim cmd As OdbcCommand = New OdbcCommand(mystring)
> oODBCConnection = New OdbcConnection(sConnString)
> oODBCConnection.Open()
>
> Dim recordcount As New OdbcCommand("Select * from Product.dbf",
> oODBCConnection)
>