Subject Re: Connection string in ADODatabase
From Mervyn Bick <invalid@invalid.invalid>
Date Mon, 26 Oct 2020 22:27:23 +0200
Newsgroups dbase.getting-started

On 2020/10/26 21:51, Gaetano wrote:
>
>
> Hi Akshat,
>
> I think you need to instantiate the database through the adodatabase
> object first, then assign it to the adoquery:
>
> Try this:
>
> msgbox(_app.inifile)

Does this serve any purpose? All it will do is show the name of the
inifile in a message box.

> d = new adodatabase()
> d.databasename="ADOinINI"
> d.active = true
> q = new adoquery()
> q.databasename = d
> q.sql = "select * from sales20"
> q.active = true
> msgbox("number of records: "+q.rowset.count())
> q.active = false
> d.active=false
> quit

For a small table it probably doesn't really matter but for a large
table you certainly don't want to fetch the entire table into memory if
all you want to do is to count the records.

Let the SQL server do the counting (which it can almost certainly do
faster than dBASE anyway) and then return one record with one field
containing the count.  This will minimise the traffic on the network.

...
q = new adoquery()
q.databasename = d
q.sql = 'select count(*) as no_rows from sales20'
q.active = true
msgbox('Number of records: '+q.rowset.fields['no_rows'].value,'Record
count')
q.active = false
q.active = false

Mervyn.