We use TMSLoader to batch insert data into a few tables without doing PutColumnData() on NOT NULL identity columns. This used to work before we upgraded, but now it raises "Unspecified Error" exceptions.
Is this change intentional?
I attach TSQL and Delphi 5 code to reproduce.
Thanks,
Carl
Code: Select all
CREATE DATABASE TestDB
GO
USE TestDB
GO
CREATE TABLE Temp_Table
(
a INTEGER IDENTITY NOT NULL,
b INTEGER NOT NULL,
c INTEGER
)
Code: Select all
program SDACTest;
{$APPTYPE CONSOLE}
uses
SysUtils, MSAccess, MSLoader, ActiveX;
type
TTestDataGenerator = class
public
procedure LoadTestData(Sender: TMSLoader);
end;
procedure TTestDataGenerator.LoadTestData(Sender: TMSLoader);
var
iRow: Integer;
begin
for iRow := 1 to 3 do
begin
//Uncomment this to fix the error:
// Sender.PutColumnData('a', iRow, 1);
Sender.PutColumnData('b', iRow, 2);
Sender.PutColumnData('c', iRow, NULL);
end;
end;
var
Connection: TMSConnection;
Loader: TMSLoader;
TestDataGenerator: TTestDataGenerator;
begin
try
CoInitialize(nil);
Connection := TMSConnection.Create(nil);
TestDataGenerator := TTestDataGenerator.Create;
Loader := TMSLoader.Create(nil);
try
Connection.ConnectString := 'Data Source=.;Initial Catalog=TestDB;User Id=sa;Password=;';
Connection.Connect;
Loader.Connection := Connection;
Loader.TableName := 'Temp_Table';
Loader.CreateColumns; //Load the table structure
Loader.OnPutData := TestDataGenerator.LoadTestData;
Loader.Load;
finally
Loader.Free;
TestDataGenerator.Free;
Connection.Free;
CoUninitialize;
end;
except
on Exc: Exception do
WriteLn(Format('%s: %s', [Exc.ClassName, Exc.Message]));
end;
Writeln('Done.');
Readln;
end.