Forum > Databases

[Solved]CREATE FULLTEXT CATALOG statement cannot be used inside user transaction

(1/3) > >>

ALAU2007:
Hi,

I want to CREATE FULLTEXT CATALOG within the program.  It shows

TMSSQL Connection: Error 574:
CREATE FULLTEXT CATALOG statement cannot be used inside a user transaction. 

uses
  SQLDB, MSSQLConn, .....

procedure TForm1.Button1Click(Sender: TObject);     
var
  Connection: TMSSQLConnection;
  Transaction: TSQLTransaction;
  Query: TSQLQuery;
begin
    Connection := TMSSQLConnection.Create(nil);
    Transaction := TSQLTransaction.Create(nil);
    Query := TSQLQuery.Create(nil);
    try
      Connection.HostName := 'hostname';
      Connection.DatabaseName := 'test1';
      Connection.UserName := 'sa';
      Connection.Password := 'password';
      Connection.Transaction := Transaction;
      Connection.Params.Add( 'AutoCommit=on');
      Transaction.DataBase := Connection;
      Query.DataBase := Connection;
      Connection.Open;
      Transaction.Commit;
      Transaction.StartTransaction;
      Query.SQL.Text := 'CREATE FULLTEXT CATALOG MyFullTextCatalog;';
      Query.ExecSQL;
    finally
        Query.Free;
        Transaction.Free;
        Connection.Free;
    end;
end;

Please help.

Zvoni:
Don't start a Transaction?

ALAU2007:
Thanks Zvoni.  I have remarked the statement to test
   
    // Transaction.StartTransaction;

It still has such error.  Please advise.  Thanks.

Zvoni:
As a test: Only create the connection (No Transaction and no TSQLQuery), and then use ExecuteDirect to check if the error still occurs.
https://www.freepascal.org/docs-html/fcl/sqldb/tsqlconnection.executedirect.html

ALAU2007:
Hi Zvoni,

I have modified my testing as:

procedure TForm1.Button2Click(Sender: TObject);
var
  Connection: TMSSQLConnection;
begin
    Connection := TMSSQLConnection.Create(nil);
    try
      Connection.HostName := 'hostname';
      Connection.DatabaseName := 'test1';
      Connection.UserName := 'sa';
      Connection.Password := 'password';
      Connection.ExecuteDirect('CREATE FULLTEXT CATALOG MyFullTextCatalog;', nil);
    finally
      Connection.Free;
    end;
    ShowMessage( 'OK');
end;                     

It shows error as:

       Transaction net set.

Thanks for your comment.

Navigation

[0] Message Index

[#] Next page

Go to full version