Resultset

Forum related to version 6.5.1 (alpha) and 6.6.x (beta) of ZeosLib's DBOs

Moderators: gto, cipto_kh, EgonHugeist

Post Reply
Jknill
Fresh Boarder
Fresh Boarder
Posts: 6
Joined: 17.02.2006, 18:04

Resultset

Post by Jknill »

hello
i want to use ZeosDBO with mysql 4.1.x
with the follow code

DBConnection1.HostName:= EdtDBServerAddress.Text;
DBConnection1.Port:=StrToInt(edtDBServerPort.text);
DBConnection1.User:=EdtDBUser.Text;
DBConnection1.Password:=edtDBPasswort.Text;
DBConnection1.Catalog:='mysql-4.1';
DBConnection1.Connect;
Query1.SQL.Clear;
Query1.Sql.Text:='Show DataBases';
Query1.Open;

but i get a EZSQLException "Can not open a resultset" after i open the Query

what is wrong with my code?

thanks for Help
matsgefvert
Junior Boarder
Junior Boarder
Posts: 38
Joined: 22.11.2005, 09:11
Location: Skövde, Sweden
Contact:

Post by matsgefvert »

I use Zeos-6.1.5, so I don't know if anything has changed, but based on that version...

DBConnection1.Catalog should not by 'mysql-4.1'. You should assign that to Protocol instead. The Catalog property should be left blank. Actually, I have no idea what Catalog does myself, I never had to touch it.

Also, you haven't assigned anything to DBConnection1.Database. If you want to connect to a MySQL server without specifying a database name, you should consider setting DBConnection1.Properties to "dbless=true", this way it won't try to connect to a specific database, it just connects to the server.

And, oh... "Query1.SQL.Clear" is unnecessary. :)

/ Mats
Coffee clarifies the mind, improves morale, lifts the spirit and motivates and inspires to focused, productive work.
zippo
Silver Boarder
Silver Boarder
Posts: 322
Joined: 12.10.2005, 18:01
Location: Slovenia

Post by zippo »

I agree. Correct the code like this:

DBConnection1.HostName:= EdtDBServerAddress.Text;
DBConnection1.Port:=StrToInt(edtDBServerPort.text);
DBConnection1.User:=EdtDBUser.Text;
DBConnection1.Password:=edtDBPasswort.Text;
DBConnection1.Protocol:='mysql-4.1'; (this can also be set designtime)
DBConnection1.Database := 'mysql'; (replace mysql with own DB)
DBConnection1.Connect;
Query1.Sql.Text:='Show DataBases';
Query1.Open;

Post if works... :)
Jknill
Fresh Boarder
Fresh Boarder
Posts: 6
Joined: 17.02.2006, 18:04

Post by Jknill »

Hi
thanks for the Answers

zippo i have change my code but it do not change the result

i get in this function "0" for the result

function TZMySQL41PlainDriver.ExecQuery(Handle: PZMySQLConnect;
const Query: PChar): Integer;
begin
Result := ZPlainMySql41.mysql_query(Handle, Query);
end;

thanks
Jknill
Fresh Boarder
Fresh Boarder
Posts: 6
Joined: 17.02.2006, 18:04

Post by Jknill »

Hi

i have found a interesting thing

if i execute ( activate the DbConnection and set the active property of the Query) at the designtime i get the result!

but if i compile this code t get the error not resultset was created

Jürgen
Jknill
Fresh Boarder
Fresh Boarder
Posts: 6
Joined: 17.02.2006, 18:04

Post by Jknill »

Hi

i have found the problem (i hope the fix is OK)

function TZMySQLStatement.ExecuteQuery(SQL: string): IZResultSet;
begin
Result := nil;
if FPlainDriver.ExecQuery(FHandle, PChar(SQL)) = 0 then
begin
DriverManager.LogMessage(lcExecute, FPlainDriver.GetProtocol, SQL);
if FPlainDriver.GetStatus(FHandle) = MYSQL_STATUS_READY then
raise EZSQLException.Create(SCanNotOpenResultSet);
Result := CreateResultSet(SQL);
end else
CheckMySQLError(FPlainDriver, FHandle, lcExecute, SQL);
end;

and now my change

if not (FPlainDriver.GetStatus(FHandle) = MYSQL_STATUS_READY) then
raise EZSQLException.Create(SCanNotOpenResultSet);

i think if the status is not ready the function do create the error ?

Juergen
rgn
Fresh Boarder
Fresh Boarder
Posts: 1
Joined: 02.05.2006, 13:20

Post by rgn »

i have the same problem with D2006-FB1.5.3-Zeos 6.5.1alpha

error is in :

Code: Select all

function TZInterbase6PreparedStatement.ExecuteQueryPrepared
...
if (StatementType in [stSelect, stExecProc])
        and (SQLData.GetFieldCount <> 0) then
...
else
        raise EZSQLException.Create(SCanNotRetrieveResultSetData);
...
im geting SQLData.GetFieldCount =0 and error pop-ups :roll:

any ideas?

thx
Post Reply