Page 1 of 1

Resultset

Posted: 18.02.2006, 16:40
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

Posted: 18.02.2006, 22:30
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

Posted: 18.02.2006, 23:40
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... :)

Posted: 19.02.2006, 09:51
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

Posted: 19.02.2006, 10:19
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

Posted: 19.02.2006, 11:43
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

Posted: 02.05.2006, 13:27
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