When I try to execute the following code using FreeTDS the program exits without any exception. When I use address and port instead of named pipe it hangs out indefinitely. When I add timeout with TZConnection.Properties it throws "Access violation at address 00000000 in module 'Test.exe'. Read of address 00000000":
Code: Select all
program Test;
{$apptype console}
uses
SysUtils, ZDataset, ZAbstractConnection, ZConnection;
procedure FreeTdsTest();
var
c: TZConnection;
begin
c := nil;
try
c := TZConnection.Create(nil);//sybdb.dll
c.Protocol := 'FreeTds_MsSQL>=2005';
c.HostName := '.\sqlexpress';//or c.HostName with ip and c.Port with port and c.Properties.Add with timeout
c.Database := 'master';
c.User := 'sa';
c.Password := '1';
c.LoginPrompt := false;
c.UseMetadata := false;
c.Connect();//here
c.Disconnect();
finally
c.Free();
end;
end;
begin
try
FreeTdsTest();
except on e: Exception do begin
Write(e.Message, #10);
end end;
end.
Code: Select all
program Test;
{$apptype console}
uses
SysUtils, ZDataset, ZAbstractConnection, ZConnection;
procedure OleDbTest();
var
c: TZConnection;
q: TZQuery;
begin
c := nil;
q := nil;
try
c := TZConnection.Create(nil);
q := TZQuery.Create(nil);
c.Protocol := 'OleDB';
c.Database := 'Provider=MSOLEDBSQL.1;Data Source=.\sqlexpress;Database=master';
c.User := 'sa';
c.Password := '1';
c.LoginPrompt := false;
c.UseMetadata := false;
q.Connection := c;
q.ParamCheck := false;
c.Connect();
q.Sql.Add('create table #t (i int)');
q.Sql.Add('insert into #t values (0)');
q.Sql.Add('select * from #t');
q.Sql.Add('drop table #t');
q.Open();//here
Write(q.RecordCount, #10);
q.Close();
c.Disconnect();
finally
q.Free();
c.Free();
end;
end;
begin
try
OleDbTest();
except on e: Exception do begin
Write(e.Message, #10);
end end;
end.