libgda.cs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. //
  2. // System.Data.OleDb.libgda
  3. //
  4. // Authors:
  5. // Rodrigo Moya ([email protected])
  6. // Tim Coleman ([email protected])
  7. //
  8. // Copyright (C) Rodrigo Moya, 2002
  9. // Copyright (C) Tim Coleman, 2002
  10. //
  11. using System.Data;
  12. using System.Data.Common;
  13. using System.Runtime.InteropServices;
  14. namespace System.Data.OleDb
  15. {
  16. internal enum GdaCommandOptions {
  17. IgnoreErrors = 1,
  18. StopOnErrors = 1 << 1,
  19. BadOption = 1 << 2,
  20. };
  21. internal enum GdaCommandType {
  22. Sql = 0,
  23. Xml = 1,
  24. Procedure = 2,
  25. Table = 3,
  26. Schema = 4,
  27. Invalid = 5
  28. };
  29. sealed internal class libgda
  30. {
  31. private static IntPtr m_gdaClient = IntPtr.Zero;
  32. static libgda ()
  33. {
  34. gda_init ("System.Data.OleDb", "0.1", 0, null);
  35. }
  36. public static IntPtr GdaClient
  37. {
  38. get {
  39. if (m_gdaClient == IntPtr.Zero)
  40. m_gdaClient = gda_client_new ();
  41. return m_gdaClient;
  42. }
  43. }
  44. [DllImport("gda-2")]
  45. public static extern void gda_init (string app_id, string version, int nargs, string[] args);
  46. [DllImport("gda-2")]
  47. public static extern IntPtr gda_client_new ();
  48. [DllImport("gda-2")]
  49. public static extern IntPtr gda_client_open_connection (IntPtr client, string dsn, string username, string password);
  50. [DllImport("gda-2")]
  51. public static extern bool gda_connection_is_open (IntPtr cnc);
  52. [DllImport("gda-2")]
  53. public static extern bool gda_connection_close (IntPtr cnc);
  54. [DllImport("gda-2")]
  55. public static extern string gda_connection_get_database (IntPtr cnc);
  56. [DllImport("gda-2")]
  57. public static extern string gda_connection_get_dsn (IntPtr cnc);
  58. [DllImport("gda-2")]
  59. public static extern string gda_connection_get_cnc_string (IntPtr cnc);
  60. [DllImport("gda-2")]
  61. public static extern string gda_connection_get_provider (IntPtr cnc);
  62. [DllImport("gda-2")]
  63. public static extern string gda_connection_get_username (IntPtr cnc);
  64. [DllImport("gda-2")]
  65. public static extern string gda_connection_get_password (IntPtr cnc);
  66. [DllImport("gda-2")]
  67. public static extern IntPtr gda_transaction_new (string name);
  68. [DllImport("gda-2")]
  69. public static extern IntPtr gda_transaction_get_name (IntPtr xaction);
  70. [DllImport("gda-2")]
  71. public static extern IntPtr gda_transaction_set_name (IntPtr xaction, string name);
  72. [DllImport("gda-2")]
  73. public static extern bool gda_connection_begin_transaction (IntPtr cnc, IntPtr xaction);
  74. [DllImport("gda-2")]
  75. public static extern bool gda_connection_commit_transaction (IntPtr cnc, IntPtr xaction);
  76. [DllImport("gda-2")]
  77. public static extern bool gda_connection_rollback_transaction (IntPtr cnc, IntPtr xaction);
  78. [DllImport("gda-2")]
  79. public static extern int gda_connection_execute_non_query (IntPtr cnc, IntPtr command, IntPtr parameterList);
  80. [DllImport("gda-2")]
  81. public static extern IntPtr gda_connection_execute_single_command (IntPtr cnc, IntPtr command, IntPtr parameterList);
  82. [DllImport("gda-2")]
  83. public static extern IntPtr gda_command_new (string text, int type, int options);
  84. }
  85. }