SQL Server Compact 4.0 and default values

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
stojo303
Posts: 22
Joined: Mon 25 Apr 2011 07:31

SQL Server Compact 4.0 and default values

Post by stojo303 » Sat 04 Jun 2011 17:31

Hi,

I have identified a problem (?) or at least handling that differs between for example SQL Server Express and SQL Server Compact.

Example:

Code: Select all

UC2.SQL.Text := 'SELECT f1, f2, f3 FROM tblX';
with UC2 do
begin
  Open;
  Insert;
  FieldByName('f1').Value := UC1.FieldByName('f1').Value;
  FieldByName('f2').Value := UC1.FieldByName('f2').Value;
  FieldByName('f3').Value := UC1.FieldByName('f3').Value;
  Post;
end;
(UC1 and UC2 are of type TUniQuery, UC1 has been opened before, f1 = string, f2 = string, f3 = int, nullable)

The following works fine with SQL Server Express, but with SQL Compact the assignment of f3 will fail if the value from UC1 is NULL.

Can I get around this somehow with some parameter or such or do I need to rewrite my code?

Thanks in advance, if neccessary, I can provide full example code.

stojo303
Posts: 22
Joined: Mon 25 Apr 2011 07:31

Post by stojo303 » Sun 05 Jun 2011 09:54

Minimal example code and database sent to your support.

AndreyZ

Post by AndreyZ » Mon 06 Jun 2011 11:14

Hello,

To solve the problem, you should set the RequiredFields option to False in the following way:

Code: Select all

UC2.Options.RequiredFields := False;

stojo303
Posts: 22
Joined: Mon 25 Apr 2011 07:31

Post by stojo303 » Mon 06 Jun 2011 12:58

Thanks! That seems to work very well (somemore testing is needed though!)

Great support as always!

AndreyZ

Post by AndreyZ » Mon 06 Jun 2011 13:08

If any other questions come up, please contact us.

Post Reply