D8 odd SqlConnection error
From: David Godwin (dagodwin_at_tagfolio.com)
Date: 01/22/04
- Previous message: Dennis: "Re: Re: Re: Login form is not responsive when connecting to the DB"
- Next in thread: Dennis: "Re: D8 odd SqlConnection error"
- Reply: Dennis: "Re: D8 odd SqlConnection error"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 22 Jan 2004 13:16:53 -0500
I'm beginning to work with the new D8 using winforms and came across a
peculiar issue. Take the following code, which loads a connection string
and uses it to open a SqlConnection object:
procedure CreateDBConnection(var NewConnection: SqlConnection; const DBName:
string);
var
conMaster: SqlConnection;
cmd: SqlCommand;
drData: SqlDataReader;
strSQL, strConnect: string;
begin
cmdTag := nil;
drData := nil;
strConnect := '';
// conMaster is setup here...
try
try
// strSQL is generated here...
cmd := SqlCommand.Create(strSQL, conMaster);
drData := cmd.ExecuteReader;
if drData.Read then
strConnect := drData.GetString(0);
NewConnection := SqlConnection.Create(strConnect);
NewConnection.Open;
except
on E:Exception do
raise Exception.Create('[CreateDBConnection] ' + E.Message);
end;
finally
if drData <> nil then drData.Free;
if cmd <> nil then cmd.Free;
conMaster.Free;
end;
end;
If for some reason strConnect is invalid, an exception is raised out just as
would be expected. However, when strConnect is valid, the Create and Open
statements execute correctly but control passes to the exception handler
with E.Message equalling "function call terminated by exception". To make
this even stranger, no exception is raised out of the procedure!
NewConnection is correctly initialized, and everything works as normal.
Even though everything works, I'm left feeling like something is broken.
Does anyone have any idea what's going on?
Thanks in advance,
David
- Previous message: Dennis: "Re: Re: Re: Login form is not responsive when connecting to the DB"
- Next in thread: Dennis: "Re: D8 odd SqlConnection error"
- Reply: Dennis: "Re: D8 odd SqlConnection error"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|