Article View: borland.public.cppbuilder.database.ado
Article #5973Help ! ADO/ADOEXPRESS or SQLServer/MSDE with ORDER BY looses the first record !
From: Erba Andrea
Date: Thu, 07 Dec 2000 14:04
Date: Thu, 07 Dec 2000 14:04
47 lines
2700 bytes
2700 bytes
Hello, I'm moving a database from Access to MSDE-SQLServer.
I have a very strange bug executing a simple query:
With ClientSide Cursor all works in the correct way.
With ServerSide Cursor happens this thing:
the same SQL expression loose the first record if I include the clause
"ORDER BY" !
example: table "USERS" contains 10 records; with:
sql1 = "SELECT * FROM USERS" the code below return 10 records;
the same code with the "ORDER BY" and any field name return 9 records,
loosing the first!
void __fastcall record_count() {
int count;
TADOQuery * q;
AnsiString conn_str = "Provider=SQLOLEDB.1;Persist Security
Info=True;User ID=SA;Data Source=MYSERVER;";
AnsiString sql1 = "SELECT * FROM USERS";
AnsiString sql2 = "SELECT * FROM USERS ORDER BY NAME";
count = 0;
q = new TADOQuery(this);
q->ConnectionString = conn_str;
q->CursorLocation = clUseServer;
q->SQL->Clear();
q->SQL->Add(sql2);
q->Open();
q->First();
while (!q->Eof) {
count ++;
q->Next();
}
ShowMessage("Number of records = " + IntToStr(count));
}
Maybe it's a problem of MSDE and serverside cursor, but I can't do other
tests
and I have to solve the problem as soon as possible.
(If could be of help: if I try to link a TDBGrid with ServerSide cursor
raises the exception "dataset doesn't support bookmarks etc...")
Can anyone help me ? Thank you!
andrea
I use Borland C++Builder Pro 5.0 with the first Update Patch,
ADOExpress with or without the ADOPatch of CodeCentral
MSDE from Microsoft Office 2000 professional (italian version);
the table is very simple with a ID= Primarykey and few Text fields
Technical Details
Message-ID:
<3A2F98FC.EBAF1948@tin.it>Path:
arc1-ca.pugleaf.net!supernews.google.com!sn-xit-02!supernews.com!isdnet!newsfeeds.belnet.be!naxos.belnet.be!news.belnet.be!bornews.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10698b,f1c769174b52ac65,start X-Google-Attributes: gid10698b,public X-Google-ArrivalTime: 2000-12-07 06:09:10 PST Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-02!supernews.com!isdnet!newsfeeds.belnet.be!naxos.belnet.be!news.belnet.be!bornews.borland.com!not-for-mail From: Erba Andrea <andrea.erba@tin.it> Newsgroups: borland.public.cppbuilder.database.ado Subject: Help ! ADO/ADOEXPRESS or SQLServer/MSDE with ORDER BY looses the first record ! Date: Thu, 07 Dec 2000 15:04:44 +0100 Organization: Another Netscape Collabra Server User Lines: 48 Message-ID: <3A2F98FC.EBAF1948@tin.it> NNTP-Posting-Host: 213.45.129.42 Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 4.73 [en] (Windows NT 5.0; U) X-Accept-Language: en