Hello,
I am doing something like following, but in this part I want to set the DATEFORMAT to mdy at this level, because I do not want to send it for each connection I open, Is there any way to set it at this level?
Thanks,
Ali
MSCon:=TMSConnection.Create(nil);
if sPayUsername='' then
MSCon.Authentication:=auWindows else
MSCon.Authentication:=auServer;
MSCon.Server:=sPayServer;
MSCon.DataBase:=sPayDatabase;
MSCon.UserName:=sPayUsername;
MSCon.Password:=sPayPassword;
MSCon.ConnectionTimeout:=iPayTimeoutConnect;
MSCon.Options.DefaultLockTimeout:=iPayTimeoutCommand*1000;
CommandTimeout:=iPayTimeoutCommand;
Connection:=MSCon;
Set DateFormat mdy
Re: Set DateFormat mdy
In SDAC there is no separate option to specify a value for DATEFORMAT. To solve the described task you can use the solution proposed below or any other.
You can create a handler for the TMSConnection.AfterConnect event, in which a value for DATEFORMAT will be set, for example using the TMSConnection.ExecSQL method. An example of this code can look like this:
When creating the TMSConnection instance assign it the above handler:
You can create a handler for the TMSConnection.AfterConnect event, in which a value for DATEFORMAT will be set, for example using the TMSConnection.ExecSQL method. An example of this code can look like this:
Code: Select all
type
TMainForm = class(TForm)
...
procedure AfterConnect_SET_DATEFORMAT_mdy(Sender: TObject);
...
end;
...
procedure TMainForm.AfterConnect_SET_DATEFORMAT_mdy(Sender: TObject);
begin
TMSConnection(Sender).ExecSQL('SET DATEFORMAT mdy;');
end;
Code: Select all
MSCon:=TMSConnection.Create(nil);
...
MSCon.AfterConnect := AfterConnect_SET_DATEFORMAT_mdy;
Connection:=MSCon;