473,386 Members | 1,758 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Record Count in .net w/ ODBC connection

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)

Nov 21 '05 #1
4 3197
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)

Nov 21 '05 #2
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)


Nov 21 '05 #3
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)
>


Nov 21 '05 #4
What, read the documentation, you must be joking.... seriously, I did read
the documentation, but obviously did not "get it". Thanks for your prompt
reply.
That was the issue. What would we do without kind folks like you to help us
who are new to the .net world and SQL along!? Thanks again.

"Marina" wrote:
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)
>


Nov 21 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Kong Li | last post by:
Follow up to this thread, the latest Oracle 9i release 2 patchset (9.2.0.5) fixed the handle count leak problem. The problem is in Oracle client component. Thanks. Kong ----- From: Kong...
3
by: B Moor | last post by:
SServer PC: Win SBS 2003 with 2.6 GHz processor and 1GB RAM SQL Server 2000 v 2000.8.00.76 (sp3) MS Office 2k3 MSJet ms04-014 (latest ost sp8) MDAC v2.8 RTM ADO 2.1 vb6.exe / ADO 2.0 I...
3
by: thomasp | last post by:
I am trying to get a record count of a PHP query on a MS Acess database using ODBC with a DSN for MS ACCESS connection. I got this code from the PHP manual user notes. It seems to return the...
1
by: Justin Koivisto | last post by:
I am trying to create a report that displays a name of an advertising source and count of the number of times it was hit between certain date ranges. The data is split between two different...
3
by: J | last post by:
I've moved the database tables from the .mdb file to Sql Svr and now I have an *intermittent* problem. When I select a record from a combo box, it will intermittently pull up the wrong record. ...
0
by: Sharon | last post by:
I have a problem using with dbf file here. I have tried the code below using VB.NET with no errors. However, I use the exact same code in ASP NET, it prompt me error when I tried to insert a...
5
by: Anony Mous | last post by:
Coming off of 7.4.3 I've always used select count(*) from pg_stat_activity through the ODBC driver to obtain the number of connections to the db. I've found that with v8.0 Beta 1 that this...
4
by: Peter W Johnson | last post by:
Hi guys, I have a problem with a datagrid record count. Here is the code:- <snip> Public Class frmMerchantDeposit Inherits System.Windows.Forms.Form Dim myconnection As New...
1
by: Zuggy | last post by:
I'm trying to create a registration/login script using Access 2003. I'm using ADOdb to connect through ODBC. <?php // Connects to your Database include('adodb/adodb.inc.php'); # load code...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.