Problem with MSLoader

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
_QQN_
Posts: 1
Joined: Thu 12 Feb 2009 09:11
Location: Moscow, Russia
Contact:

Problem with MSLoader

Post by _QQN_ » Thu 12 Feb 2009 09:20

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.

Dimon
Devart Team
Posts: 2885
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Mon 16 Feb 2009 16:15

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.

Post Reply