Well, you learn something every day
However, that didn't solve my problem: I still get the same error message. And I can't make the changes permanent (which DOES solve the problem), as there are a lot of legacy apps using this database, and I have no idea how the changes will affect them.
The relevant code is below. I appreciate your help!
object qReservations: TMSQuery
DataTypeMap = <>
Connection = DevConnection
SQL.Strings = (
'select Reservations.ReservationID as ID, '
''
' [Start] = DATEADD( day, 0, DATEDIFF( day, 0, Reservations' +
'.ArrivalDate ) ) +'
' DATEADD( day, 0 - DATEDIFF( day, 0, Reservation' +
's.ArrivalTime ), Reservations.ArrivalTime ),'
''
' [Finish] = DATEADD( minute, Reservations.Duration, '
' ( DATEADD( day, 0, DATEDIFF( day, 0, Reservati' +
'ons.ArrivalDate ) ) +'
' DATEADD( day, 0 - DATEDIFF( day, 0, Reservat' +
'ions.ArrivalTime ), Reservations.ArrivalTime ) ) ),'
' '
' GROUPS.[Name] as [Caption],'
' CASE '
' WHEN Reservations.AdultQuantity = 0 then '#39'No Adults'#39
' WHEN Reservations.AdultQuantity = 1 then '#39'1 Adult'#39
' WHEN Reservations.AdultQuantity > 1 then CAST( Reservat' +
'ions.AdultQuantity as VarChar ) + '#39' Adults'#39
' END + '#39' / '#39' +'
' CASE '
' WHEN Reservations.ChildQuantity = 0 then '#39'No Children'#39
' WHEN Reservations.ChildQuantity = 1 then '#39'1 Child'#39
' WHEN Reservations.ChildQuantity > 1 then CAST( Reservat' +
'ions.ChildQuantity as VarChar ) + '#39' Children'#39
' END as Location, '
' 0 as EventType,'
' 2 as [Options],'
' Reservations.ColorCode as LabelColor,'
' Reservations.Comments as [Message]'
'from Res_Reservations Reservations'
' Join Res_Groups Groups on ( Groups.GroupId = Reservations.G' +
'roupId )'
''
'Where ( Reservations.Cancelled = 0 ) and ( Reservations.ArrivalD' +
'ate >= (GetDate() -365 ) )'
'Order By Start')
Options.ReflectChangeNotify = True
ChangeNotification = MSChangeNotification1
Left = 112
Top = 16
end
object dsReservations: TMSDataSource
AutoEdit = False
DataSet = qReservations
Left = 193
Top = 16
end
object DevConnection: TMSConnection
Database = 'IWM'
Options.Provider = prNativeClient
Options.KeepDesignConnected = False
Options.NativeClientVersion = ncAuto
DataTypeMap = <>
Username = 'sa'
Password = 'qwertypoiuyt'
Server = 'RALPH'
AfterConnect = DevConnectionAfterConnect
BeforeDisconnect = DevConnectionBeforeDisconnect
LoginPrompt = False
Left = 25
Top = 16
end
object MSChangeNotification1: TMSChangeNotification
Enabled = False
OnChange = MSChangeNotification1Change
Left = 376
Top = 32
end
=======================================================================
procedure TForm1.Button1Click(Sender: TObject);
begin
qReservations.Active := DevConnection.Connected;
end;
procedure TForm1.DevConnectionAfterConnect(Sender: TObject);
begin
DevConnection.ExecSQL('SET ANSI_NULLS ON;' +
'SET ANSI_PADDING ON;' +
'SET ANSI_WARNINGS ON;' +
'SET CONCAT_NULL_YIELDS_NULL ON;' +
'SET QUOTED_IDENTIFIER ON;' +
'SET NUMERIC_ROUNDABORT OFF;' +
'SET ARITHABORT ON;', []);
end;
procedure TForm1.DevConnectionBeforeDisconnect(Sender: TObject);
begin
MSChangeNotification1.Enabled := False;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
DevConnection.Connected := True;
MSChangeNotification1.Enabled := DevConnection.Connected;
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
qReservations.Active := False;
DevConnection.Connected := False;
end;
procedure TForm1.MSChangeNotification1Change(Sender: TObject; DataSet: TCustomMSDataSet; NotificationInfo: TMSNotificationInfo; NotificationSource: TMSNotificationSource; NotificationType: TMSNotificationType);
begin
Memo1.Lines.Add( Format( 'Change Occurred on %s : %s : %s : %s', [ DataSet.Name,
GetEnumName( TypeInfo( TMSNotificationInfo ), Integer( NotificationInfo ) ),
GetEnumName( TypeInfo( TMSNotificationSource ), Integer( NotificationSource ) ),
GetEnumName( TypeInfo( TMSNotificationType ), Integer( NotificationType ) ) ] ) );
end;