Subject Re: could not find UNIQUE INDEX with specified columns
Author troller507
--- In firebird-support@yahoogroups.com, Helen Borrie <helebor@...> wrote:
>
> At 19:20 16/10/2008, you wrote:
>
> >Hi
> >
> >CREATE TABLE test (field1 integer, field2 char(1024), field3 integer,
> >PRIMARY KEY (field1))
> >
> >After:
> >
> >ALTER TABLE test ADD FOREIGN KEY (field3) REFERENCES test(field1)
> >
> >Throws: could not find UNIQUE INDEX with specified columns
>
> You need to commit the first statement before the second one will work.
>
> ./heLen
>

Hi

FbConnection c = new
FbConnection("ServerType=1;User=SYSDBA;Password=masterkey;Dialect=3;Database=mydb.fdb");

c.Open();
FbTransaction t = c.BeginTransaction();
FbCommand cmd = new FbCommand("CREATE TABLE \"test\"
(field1 integer, field2 char(1024), field3 integer, PRIMARY KEY
(field1))", c, t);
cmd.ExecuteNonQuery();
t.Commit();
t.Dispose();
t = c.BeginTransaction();
FbCommand cmd1 = new FbCommand("ALTER TABLE \"test\" ADD
FOREIGN KEY (field3) REFERENCES test(field1)", c, t);
cmd1.ExecuteNonQuery();
t.Commit();
t.Dispose();
c.Close();

Throws Unhandled Exception: FirebirdSql.Data.Firebird.FbException:
unsuccessful metadat a update could not find UNIQUE INDEX with
specified columns

Regards

Joe