public override void Prepare(string commandText) { // Clear data this.Clear(); this.parameters = null; this.fields = null; lock (this.db) { if (this.state == StatementState.Deallocated) { // Allocate statement this.Allocate(); } // Marshal structures to pointer XsqldaMarshaler marshaler = XsqldaMarshaler.GetInstance(); // Setup fields structure this.fields = new Descriptor(1); IntPtr sqlda = marshaler.MarshalManagedToNative(this.db.Charset, this.fields); int[] statusVector = FesConnection.GetNewStatusVector(); int trHandle = this.transaction.Handle; int stmtHandle = this.handle; byte[] buffer = this.db.Charset.GetBytes(commandText); FbClient.isc_dsql_prepare( statusVector, ref trHandle, ref stmtHandle, (short)buffer.Length, buffer, this.db.Dialect, sqlda); // Marshal Pointer Descriptor descriptor = marshaler.MarshalNativeToManaged(this.db.Charset, sqlda); // Free memory marshaler.CleanUpNativeData(ref sqlda); // Parse status vector this.db.ParseStatusVector(statusVector); // Describe fields this.fields = descriptor; if (this.fields.ActualCount > 0 && this.fields.ActualCount != this.fields.Count) { this.Describe(); } else { if (this.fields.ActualCount == 0) { this.fields = new Descriptor(0); } } // Reset actual field values this.fields.ResetValues(); // Get Statement type this.statementType = this.GetStatementType(); // Update state this.state = StatementState.Prepared; } }