+2002-07-30 Rodrigo Moya <rodrigo@ximian.com>
+
+ * OleDbDataReader.cs (FieldCount): implemented.
+ (IsClosed, Item, RecordsAffected): implemented some properties.
+
+ * libgda.cs: added GdaDataModel methods.
+
2002-07-29 Rodrigo Moya <rodrigo@ximian.com>
* OleDbDataReader.cs (OleDbDataReader constructor): changed to receive
private bool open;
private ArrayList gdaResults;
private int currentResult;
+ private int currentRow;
+ private bool isOpened;
#endregion
{
this.command = command;
open = true;
- gdaResults = results;
+ if (results != null)
+ gdaResults = results;
+ else
+ gdaResults = new ArrayList ();
currentResult = -1;
+ currentRow = -1;
command.OpenReader(this);
+ isOpened = true;
}
#endregion
}
public int FieldCount {
- [MonoTODO]
- get { throw new NotImplementedException (); }
+ get {
+ if (currentResult < 0 ||
+ currentResult >= gdaResults.Count)
+ return 0;
+
+ return libgda.gda_data_model_get_n_columns (
+ (IntPtr) gdaResults[currentResult]);
+ }
}
public bool IsClosed {
- [MonoTODO]
- get { throw new NotImplementedException (); }
+ get {
+ return !isOpened;
+ }
}
public object this[string name] {
}
public object this[int index] {
- [MonoTODO]
- get { throw new NotImplementedException (); }
+ get {
+ if (currentResult < 0 ||
+ currentResult >= gdaResults.Count)
+ return null;
+
+ return libgda.gda_data_model_get_value_at (
+ (IntPtr) gdaResults[currentResult],
+ index,
+ currentRow);
+ }
}
public int RecordsAffected {
- [MonoTODO]
- get { throw new NotImplementedException (); }
+ get {
+ int total_rows;
+
+ if (currentResult < 0 ||
+ currentResult >= gdaResults.Count)
+ return 0;
+
+ total_rows = libgda.gda_data_model_get_n_rows (
+ (IntPtr) gdaResults[currentResult]);
+ if (total_rows > 0) {
+ if (FieldCount > 0) {
+ // It's a SELECT statement
+ return -1;
+ }
+ }
+
+ return FieldCount > 0 ? -1 : total_rows;
+ }
}
#endregion
[DllImport("gda-2")]
public static extern void gda_init (string app_id, string version, int nargs, string[] args);
+ [DllImport("gda-2")]
+ public static extern int gda_data_model_get_n_rows (IntPtr model);
+
+ [DllImport("gda-2")]
+ public static extern int gda_data_model_get_n_columns (IntPtr model);
+
+ [DllImport("gda-2")]
+ public static extern IntPtr gda_data_model_get_value_at (IntPtr model, int col, int row);
+
[DllImport("gda-2")]
public static extern IntPtr gda_client_new ();