[patch_done] SQL Server Plain Driver Access Violation

Freature requests from users for ZeosLib's DBOs

Moderators: gto, cipto_kh, EgonHugeist, mdaems

Post Reply
jcardarelli
Fresh Boarder
Fresh Boarder
Posts: 2
Joined: 04.12.2011, 00:14

[patch_done] SQL Server Plain Driver Access Violation

Post by jcardarelli »

Hi Developer Team !


For years I'm using ZEOS and I think that the performance is very good.

Now, I'm using the suite to develop a web project using IntraWeb and building a ISAPI dll running over IIS6 and Windows Server 2003.

So, I need to access the SQL Server 2000 using low level to change the maximum connections number per each process, and studing the ZEOS code I could see an attachment to the library "ntwdblib.dll" to call the function "dbsetmaxprocs", used to set the value I'm trying to change. But, the implementation of ZEOS Plain Driver uses the function below to that work:


function TZDBLibMSSQL7PlainDriver.dbsetmaxprocs(
MaxProcs: SmallInt): RETCODE;


The question is: the implementation inside this function uses a wrong object not created, but used to do that work to a SYBASE server. And without an instance the result is an access violation.

Inside the begin..end block, I replaced:

Result := ZPlainDBLibSybaseASE125.dbsetmaxprocs(MaxProcs);

TO

Result := ZPlainDbLibMsSql7.dbsetmaxprocs(MaxProcs);


Now, the function don't raise an exception. And here is the full function that I wrote to understand better the environment:


class function TDatabaseManager.ConfigureMSSQL2000MaxDBProcesses(const Host, Login, Password: String; const MaxConnections: SmallInt): Boolean;
var
driver : TZDBLibMSSQL7PlainDriver;
pLogin, pProc : Pointer;
begin
Result := False;

if (MaxConnections <= 0) then
Exit;

Result := True;
driver := TZDBLibMSSQL7PlainDriver.Create;

try
try
with driver do begin
pLogin := nil;
//driver initialization and loading dll "ntwdblib.dll" (SQL Server)
Initialize;
//I get the pointer to login
pLogin := driver.dbLogin;
//setting the parameters to driver connection
dbSetLHost(pLogin, PChar(Host));
dbSetLUser(pLogin, PChar(Login));
dbSetLPwd(pLogin, PChar(Password));
//I get the process pointer and connect on the server
pProc := dbOpen(pLogin, PChar(Host));
//setting the maximum number of connections to the process using the connection stablished
dbSetMaxprocs(MaxConnections);
//closing de connection
dbClose(pProc);
end;
except
Result := False;
end;
finally
//to destroy the driver object
FreeAndNil(driver);
pProc := nil; //it dosen't matter, but...
pLogin := nil; //it dosen't matter, but...
end;
end;



I hope to help you to produce a new release.


Regards,

Juliano Cardarelli
Last edited by jcardarelli on 17.12.2011, 23:14, edited 1 time in total.
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

PHP code?
What zeoslib version uses PHP?

Mark
Image
jcardarelli
Fresh Boarder
Fresh Boarder
Posts: 2
Joined: 04.12.2011, 00:14

Post by jcardarelli »

Sorry Mark,

It's my fault.

I'm waiting for a new review of my post and I think that now, you can know better when is the problem.



Thanks,

Juliano
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

Patch done in SVN rev 967.

Mark
Image
Post Reply