TMSLoader "Unspecified Error" exception in new versions...

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
carlmon
Posts: 7
Joined: Thu 16 Oct 2008 09:49

TMSLoader "Unspecified Error" exception in new versions...

Post by carlmon » Wed 25 Aug 2010 11:47

Greetings,

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.

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

Post by Dimon » Thu 26 Aug 2010 10:00

Thank you for information. We have reproduced this problem and fixed it. This fix will be included in the next SDAC build.

Post Reply