bool designTimeVisible;
OleDbDataReader dataReader;
CommandBehavior behavior;
- ArrayList gdaCommands;
+ IntPtr gdaCommand;
ArrayList gdaResults;
#endregion // Fields
designTimeVisible = false;
dataReader = null;
behavior = CommandBehavior.Default;
- gdaCommands = new ArrayList ();
+ gdaCommand = IntPtr.Zero;
gdaResults = new ArrayList ();
}
{
get { return commandText; }
set {
- string[] queries = value.Split (new Char[] {';'});
- gdaCommands.Clear ();
-
- foreach (string query in queries)
- gdaCommands.Add (libgda.gda_command_new (query, 0, 0));
-
- commandText = value;
+ commandText = value;
}
}
return new OleDbParameter ();
}
+ IDbDataParameter IDbCommand.CreateParameter ()
+ {
+ return CreateParameter ();
+ }
+
[MonoTODO]
protected override void Dispose (bool disposing)
{
throw new NotImplementedException ();
}
+ private void SetupGdaCommand ()
+ {
+ GdaCommandType type;
+
+ switch (commandType) {
+ case CommandType.TableDirect :
+ type = GdaCommandType.Table;
+ break;
+ case CommandType.StoredProcedure :
+ type = GdaCommandType.Procedure;
+ break;
+ case CommandType.Text :
+ default :
+ type = GdaCommandType.Sql;
+ break;
+ }
+
+ if (gdaCommand != IntPtr.Zero) {
+ libgda.gda_command_set_text (gdaCommand, commandText);
+ libgda.gda_command_set_command_type (gdaCommand, type);
+ } else {
+ gdaCommand = libgda.gda_command_new (commandText, type, 0);
+ }
+
+ //libgda.gda_command_set_transaction
+ }
+
public int ExecuteNonQuery ()
{
if (connection == null)
IntPtr gdaConnection = connection.GdaConnection;
IntPtr gdaParameterList = parameters.GdaParameterList;
- return libgda.gda_connection_execute_non_query (gdaConnection, (IntPtr) gdaCommands[0], gdaParameterList);
+ SetupGdaCommand ();
+ return libgda.gda_connection_execute_non_query (gdaConnection, (IntPtr) gdaCommand, gdaParameterList);
}
public OleDbDataReader ExecuteReader ()
return ExecuteReader (CommandBehavior.Default);
}
+ IDataReader IDbCommand.ExecuteReader ()
+ {
+ return ExecuteReader ();
+ }
+
public OleDbDataReader ExecuteReader (CommandBehavior behavior)
{
if (connection.State != ConnectionState.Open)
IntPtr gdaConnection = connection.GdaConnection;
IntPtr gdaParameterList = parameters.GdaParameterList;
- foreach (IntPtr gdaCommand in gdaCommands)
- GdaResults.Add (libgda.gda_connection_execute_single_command (gdaConnection, gdaCommand, gdaParameterList));
+ /* FIXME: split all returned resultsets into
+ our internal GdaResults */
+ GdaResults.Add (libgda.gda_connection_execute_command (
+ gdaConnection,
+ gdaCommand,
+ gdaParameterList));
dataReader = new OleDbDataReader (this);
-
dataReader.NextResult ();
return dataReader;
}
- [MonoTODO]
- public object ExecuteScalar ()
- {
- throw new NotImplementedException ();
- }
-
- [MonoTODO]
- object ICloneable.Clone ()
- {
- throw new NotImplementedException ();
- }
-
- [MonoTODO]
- IDbDataParameter IDbCommand.CreateParameter ()
+ IDataReader IDbCommand.ExecuteReader (CommandBehavior behavior)
{
- throw new NotImplementedException ();
+ return ExecuteReader (behavior);
}
-
+
[MonoTODO]
- IDataReader IDbCommand.ExecuteReader ()
+ public object ExecuteScalar ()
{
throw new NotImplementedException ();
}
[MonoTODO]
- IDataReader IDbCommand.ExecuteReader (CommandBehavior behavior)
+ object ICloneable.Clone ()
{
throw new NotImplementedException ();
}
[DllImport("gda-2")]
public static extern bool gda_connection_rollback_transaction (IntPtr cnc, IntPtr xaction);
+ [DllImport("gda-2")]
+ public static extern IntPtr gda_connection_execute_command (IntPtr cnc, IntPtr cmd, IntPtr parameterList);
+
[DllImport("gda-2")]
public static extern int gda_connection_execute_non_query (IntPtr cnc, IntPtr command, IntPtr parameterList);
public static extern IntPtr gda_connection_execute_single_command (IntPtr cnc, IntPtr command, IntPtr parameterList);
[DllImport("gda-2")]
- public static extern IntPtr gda_command_new (string text, int type, int options);
+ public static extern IntPtr gda_command_new (string text, GdaCommandType type, GdaCommandOptions options);
+
+ [DllImport("gda-2")]
+ public static extern void gda_command_set_text (IntPtr cmd, string text);
+
+ [DllImport("gda-2")]
+ public static extern void gda_command_set_command_type (IntPtr cmd, GdaCommandType type);
}
}