for that example the surroundings will be
// somwere here transaction is started
IDbCommand com = connection.CreateCommand();
com.Transaction = trans;
com.CommandText = "Delete from KnownEntityTypes where id=@Id; Delete from KnownPropertyTypes where ENTITY_TYPE_ID=@Id; ";
DBUtils.addCommandParam(com, "@Id", type.Id); // my function to add parameter and set it value to type.Id that is Guid
com.ExecuteNonQuery(); // AccessViolation occurs
Also there is another exception, that occurs during first launch of application when database is just created
com.CommandText = "CREATE TABLE [Entity] (LOCAL_ID bigint NOT NULL , CHANGE_TYPE tinyint NULL , [Id] UNIQUEIDENTIFIER NULL , [Id$C] bit NOT NULL DEFAULT 0 , [LocalId] BIGINT NULL , [LocalId$C] bit NOT NULL DEFAULT 0 , [Version.TransactionId] UNIQUEIDENTIFIER NULL , [Version.TransactionId$C] bit NOT NULL DEFAULT 0 , [Version.Time] BIGINT NULL , [Version.Time$C] bit NOT NULL DEFAULT 0 , [Version.BaseVersionTime] BIGINT NULL , [Version.BaseVersionTime$C] bit NOT NULL DEFAULT 0 , [Version.MergedVersionTime] BIGINT NULL , [Version.MergedVersionTime$C] bit NOT NULL DEFAULT 0 , [Version.ChangedBy.Id] UNIQUEIDENTIFIER NULL , [Version.ChangedBy.Id$C] bit NOT NULL DEFAULT 0 , [Version.ChangedAtHost] UNIQUEIDENTIFIER NULL , [Version.ChangedAtHost$C] bit NOT NULL DEFAULT 0 , [Version.State] INT NULL , [Version.State$C] bit NOT NULL DEFAULT 0 , [Type.Id] UNIQUEIDENTIFIER NULL , [Type.Id$C] bit NOT NULL DEFAULT 0)";
com.ExecuteNonQuery();
System.NullReferenceException occurred
Message="Object reference not set to an instance of an object."
Source="System.Data.SQLite"
StackTrace:
at System.Data.SQLite.SQLiteStatement.Dispose()
at System.Data.SQLite.SQLite3.Reset(SQLiteStatement stmt)
at System.Data.SQLite.SQLite3.Step(SQLiteStatement stmt)
at System.Data.SQLite.SQLiteCommand.ExecuteNonQuery()
at
but if I execute command "CREATE TABLE [Entity] (LOCAL_ID bigint NOT NULL )" instead, no exception happens.
Also no exception happens if com.ExecuteNonQuery(); is executed second time