Page 1 of 1

Problem with MSLoader

Posted: Thu 12 Feb 2009 09:20
by _QQN_
Hello all
I have a proplem using MSLoader component (with using fields DEFAULT values)

Table:

USE [MyDB_1]
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[TestTable_1](
[ID] [int] IDENTITY(1,1) NOT NULL,
[DateCreate] [datetime] NOT NULL CONSTRAINT [DF_TestTable_1_DateCreate] DEFAULT (getdate()),
[CurrData] [int] NULL
) ON [PRIMARY]


Code:
dfm:
object MSLoader1: TMSLoader
Connection = MSConnection1
TableName = 'dbo.TestTable_1'
KeepIdentity = True
OnPutData = MSLoader1PutData
Left = 16
Top = 48
end

and
pas:

procedure TForm11.Button2Click(Sender: TObject);
begin
MSLoader1.KeepNulls:=False;
MSLoader1.Load;
end;


procedure TForm11.MSLoader1PutData(Sender: TMSLoader);
begin
MSLoader1.PutColumnData('ID',1,1);
MSLoader1.PutColumnData('DateCreate',1,Null);
MSLoader1.PutColumnData('CurrData',1,100);
end;
or
procedure TForm11.MSLoader1PutData(Sender: TMSLoader);
begin
MSLoader1.PutColumnData('ID',1,1);
MSLoader1.PutColumnData('CurrData',1,100);
end;

and on "Load" method Delphi raise exception (Unknown error)

Help plz !

my configuration:
Client: WinXP Sp2, Delphi CodeGear RAD Studio 2007, SDAC ver: 4.70.0.44
Server: WinServer 2003, Microsoft SQL Server Standard Edition (9.00.3042.00)

What I doing wrong?

Thank you.

Posted: Mon 16 Feb 2009 16:15
by Dimon
The problem is that the DateCreate field has NOT NULL constraint. Therefore SQL Server does not allow to insert record with NULL value into this field although the default value is defined. The TMSLoader.KeepNulls property is not employed for fields with NOT NULL constraint.