--- /dev/null
+//
+// System.Data.SqlClient.SqlClientPermission.cs
+//
+// Author:
+// Rodrigo Moya (rodrigo@ximian.com)
+// Daniel Morgan (danmorg@sc.rr.com)
+//
+// (C) Ximian, Inc 2002
+//
+
+using System;
+using System.Data;
+using System.Data.Common;
+
+namespace System.Data.SqlClient {
+
+ public sealed class SqlClientPermission : DBDataPermission {
+
+ [MonoTODO]
+ public SqlClientPermission() {
+ // FIXME: do constructor
+ }
+
+ [MonoTODO]
+ public SqlClientPermission(PermissionState state) {
+ // FIXME: do constructor
+ }
+
+ [MonoTODO]
+ public SqlClientPermission(PermissionState state,
+ bool allowBlankPassword) {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public override IPermission Copy() {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public override void FromXml(SecurityElement
+ securityElement) {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public override IPermission Intersect(IPermission target) {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public override bool IsSubsetOf(IPermission target) {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public override string ToString() {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public override SecurityElement ToXml() {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public override IPermission Union(IPermission target) {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ ~SqlClientPermission() {
+ // FIXME: destructor to release resources
+ }
+ }
+}
--- /dev/null
+//
+// System.Data.SqlClient.SqlClientPermissionAttribute.cs
+//
+// Author:
+// Rodrigo Moya (rodrigo@ximian.com)
+// Daniel Morgan (danmorg@sc.rr.com)
+//
+// (C) Ximian, Inc 2002
+//
+
+using System;
+using System.Data;
+using System.Data.Common;
+
+namespace System.Data.SqlClient {
+
+ [AttributeUsage(AttributeTargets.Assembly |
+ AttributeTargets.Class |
+ AttributeTargets.Struct |
+ AttributeTargets.Constructor |
+ AttributeTargets.Method)]
+ [Serializable]
+ public sealed class SqlClientPermissionAttribute :
+ DBDataPermissionAttribute {
+
+ [MonoTODO]
+ [AttributeUsage(AttributeTargets.Assembly |
+ AttributeTargets.Class |
+ AttributeTargets.Struct |
+ AttributeTargets.Constructor |
+ AttributeTargets.Method)]
+ [Serializable]
+ public SqlClientPermissionAttribute(SecurityAction action) {
+ // FIXME: do constructor
+ }
+
+ [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class
+ | AttributeTargets.Struct | AttributeTargets.Constructor |
+ AttributeTargets.Method)]
+ [Serializable]
+ public override IPermission CreatePermission() {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ ~SqlClientPermissionAttribute() {
+ // FIXME: destructor to release resources
+ }
+ }
+
+}
// (C) Ximian, Inc 2002
//
+// use #define DEBUG_SqlCommand if you want to spew debug messages
+// #define DEBUG_SqlCommand
+
using System;
using System.ComponentModel;
using System.Data;
ExecStatusType execStatus;
String rowsAffectedString;
- // FIXME: throw an
- // InvalidOperationException
- // exception if the the connection
- // does not exist or is not open
+ if(conn.State != ConnectionState.Open)
+ throw new InvalidOperationException("ConnnectionState is not Open");
// FIXME: PQexec blocks
// while PQsendQuery is non-blocking
pgResult = PostgresLibrary.
PQexec (conn.PostgresConnection, sql);
- /* FIXME: throw an SqlException exception
- * if there is a SQL Error
- */
-
- /*
- * FIXME: get status
- */
execStatus = PostgresLibrary.
PQresultStatus (pgResult);
if(execStatus == ExecStatusType.PGRES_COMMAND_OK)
{
- Console.WriteLine("*** SqlCommand Execute " +
- "got PGRES_COMMAND_OK");
rowsAffectedString = PostgresLibrary.
PQcmdTuples (pgResult);
- Console.WriteLine("*** Rows Affected: " +
- rowsAffectedString);
- // FIXME: convert string to number
+#if DEBUG_SqlCommand
+ Console.WriteLine("rowsAffectedString: " +
+ rowsAffectedString);
+#endif // DEBUG_SqlCommand
+ if(rowsAffectedString != null)
+ if(rowsAffectedString.Equals("") == false)
+ rowsAffected = int.Parse(rowsAffectedString);
}
else
{
- Console.WriteLine("*** Error: SqlCommand " +
- "did not get PGRES_COMMAND_OK");
- String statusString;
+ String errorMessage = "ExecuteNonQuery execution failure";
- statusString = PostgresLibrary.
+ errorMessage = PostgresLibrary.
PQresStatus(execStatus);
- Console.WriteLine("*** Command Status: " +
- statusString);
- String errorMessage;
- errorMessage = PostgresLibrary.\r
+ errorMessage += " " + PostgresLibrary.\r
PQresultErrorMessage(pgResult);\r
-\r
- Console.WriteLine("*** Error message: " +\r
- statusString);
+ \r
+ throw new SqlException(0, 0,
+ errorMessage, 0, "",
+ conn.DataSource, "SqlCommand", 0);\r
}
-
+#if DEBUG_SqlCommand
String cmdStatus;
cmdStatus = PostgresLibrary.
PQcmdStatus(pgResult);
Console.WriteLine("*** Command Status: " +
cmdStatus);
-
+#endif // DEBUG_SqlCommand
PostgresLibrary.PQclear (pgResult);
// FIXME: get number of rows
[MonoTODO]
public void Prepare ()
{
+ // FIXME: parameters have to be implemented for this
throw new NotImplementedException ();
}
#endregion // Properties
- #region Desctructors
-/*
+ #region Destructors
+
+ [MonoTODO]
+ public void Dispose() {
+ // FIXME: need proper way to release resources
+ // Dispose(true);
+ }
+
[MonoTODO]
- [ClassInterface(ClassInterfaceType.AutoDual)]
~SqlCommand()
{
- FIXME: need proper way to release resources
+ // FIXME: need proper way to release resources
+ // Dispose(false);
}
-*/
+
#endregion //Destructors
}
}
--- /dev/null
+//
+// System.Data.SqlClient.SqlCommandBuilder.cs
+//
+// Author:
+// Rodrigo Moya (rodrigo@ximian.com)
+// Daniel Morgan (danmorg@sc.rr.com)
+//
+// (C) Ximian, Inc 2002
+//
+
+using System;
+using System.Data;
+using System.ComponentModel;
+
+namespace System.Data.SqlClient {\r
+\r
+ /// <summary>\r
+ /// Builder of one command\r
+ /// that will be used in manipulating a table for\r
+ /// a DataSet that is assoicated with a database.\r
+ /// </summary>\r
+ public sealed class SqlCommandBuilder : Component {\r
+ \r
+ [MonoTODO]\r
+ public SqlCommandBuilder() {\r
+\r
+ }\r
+\r
+ [MonoTODO]\r
+ public SqlCommandBuilder(SqlDataAdapter adapter) {\r
+ \r
+ }\r
+\r
+ [MonoTODO]\r
+ public SqlDataAdapter DataAdapter {\r
+ get {\r
+ throw new NotImplementedException ();\r
+ }\r
+ \r
+ set{\r
+ throw new NotImplementedException ();\r
+ }\r
+ }\r
+\r
+ [MonoTODO]\r
+ public string QuotePrefix {\r
+ get {\r
+ throw new NotImplementedException ();\r
+ } \r
+ \r
+ set {\r
+ throw new NotImplementedException ();\r
+ }\r
+ }\r
+\r
+ [MonoTODO]\r
+ public string QuoteSuffix {\r
+ get {\r
+ throw new NotImplementedException ();\r
+ }\r
+ \r
+ set {\r
+ throw new NotImplementedException ();\r
+ }\r
+ }\r
+\r
+ [MonoTODO]\r
+ public static void DeriveParameters(SqlCommand command) {\r
+ throw new NotImplementedException ();\r
+ }\r
+\r
+ [MonoTODO]\r
+ public SqlCommand GetDeleteCommand() {\r
+ throw new NotImplementedException ();\r
+ }\r
+\r
+ [MonoTODO]\r
+ public SqlCommand GetInsertCommand() {\r
+ throw new NotImplementedException ();\r
+ }\r
+\r
+ [MonoTODO]\r
+ public SqlCommand GetUpdateCommand() {\r
+ throw new NotImplementedException ();\r
+ }\r
+\r
+ [MonoTODO]\r
+ public void RefreshSchema() {\r
+ throw new NotImplementedException ();\r
+ }\r
+\r
+ [MonoTODO]\r
+ protected override void Dispose(bool disposing) {\r
+ throw new NotImplementedException ();\r
+ }\r
+\r
+ [MonoTODO]\r
+ ~SqlCommandBuilder() {\r
+ // FIXME: create destructor - release resources\r
+ }\r
+ }\r
+}\r
+\r
// (C) Ximian, Inc 2002
//
-// FIXME: what is the proper way to debug messages?
-// use #define DEBUG_SqlConnection if you want to spew debug messages for
-#define DEBUG_SqlConnection
+// use #define DEBUG_SqlConnection if you want to spew debug messages
+// #define DEBUG_SqlConnection
using System;
using System.ComponentModel;
// ICloneable
public sealed class SqlConnection : IDbConnection
{
+ // FIXME: Need to implement class Component, \r
+ // and interfaces: ICloneable and IDisposable
+
#region Fields
private PGconn pgConn = IntPtr.Zero;
public SqlConnection (String connectionString)
{
SetConnectionString (connectionString);
- OpenDataSource ();
}
- #endregion
+ #endregion // Constructors
- #region Deconstructors
+ #region Destructors
+ [MonoTODO]
+ public void Dispose () {
+ // FIXME: release resources properly
+ Close ();
+ // Dispose (true);
+ }
+
// aka Finalize
-
-
- /*
- [ClassInterface(ClassInterfaceType.AutoDual)]
+ // [ClassInterface(ClassInterfaceType.AutoDual)]
+ [MonoTODO]
~SqlConnection()
{
-
+ // FIXME: this class need
+ // a destructor to release resources
+ // Also, take a look at Dispose
+ // Dispose (false);
}
- */
- #endregion // Deconstructors
+
+ #endregion // Destructors
#region Public Methods
return TransactionBegin (il); // call private method
}
+ // PostgreSQL does not support named transactions/savepoint
+ // nor nested transactions
+ [Obsolete]
+ public SqlTransaction BeginTransaction( string transactionName) {
+ return TransactionBegin (); // call private method
+ }
+
+ [Obsolete]
+ public SqlTransaction BeginTransaction(IsolationLevel iso,\r
+ string transactionName) {
+ return TransactionBegin (); // call private method
+ }
+
[MonoTODO]
public void ChangeDatabase (string databaseName)
{
OpenDataSource ();
}
- [MonoTODO]
- public void Dispose ()
- {
- // FIXME: quick hack
- Close ();
- // Dispose (true);
- }
-
- #endregion
+ #endregion // Public Methods
#region Internal Methods
private void OpenDataSource ()
{
+ if(dbname.Equals(""))
+ throw new InvalidOperationException("dbname missing");
+ else if(conState == ConnectionState.Open)
+ throw new InvalidOperationException("ConnnectionState is already Open");
+
ConnStatusType connStatus;
// FIXME: check to make sure we have
{
String errorMessage = PostgresLibrary.
PQerrorMessage (pgConn);
- // FIXME: use thie WriteLine's until
- // exceptions have been implemented
- Console.WriteLine("*** Error: " +
- "could not connect to database.");
- Console.WriteLine ("Error Message: " +
- errorMessage);
-
- // FIXME: do error checking,
- // if could not connect,
- // throw an exception:
- // InvalidOperationException - attempt
- // to connect to without specifying
- // database or server
- // SqlException - error while
- // connecting to database
-
+ errorMessage += ": Could not connect to database.";
+
+ throw new SqlException(0, 0,
+ errorMessage, 0, "",
+ host, "SqlConnection", 0);
}
-
}
private void CloseDataSource ()
connectionString);
#if DEBUG_SqlConnection
- Console.WriteLine("DEBUG_SqlConnection: " +
- "SqlConnection.pgConnectionString: " +
+ Console.WriteLine(
+ "OLE-DB Connection String [in]: " +
+ this.ConnectionString);
+ Console.WriteLine(
+ "Postgres Connection String [out]: " +
pgConnectionString);
- Console.WriteLine("DEBUG_SqlConnection: " +
- "SqlConnection.connectionString: " +
- this.connectionString);
#endif // DEBUG_SqlConnection
}
case "password":
password = parmValue;
- addParm = false;
+ // addParm = false;
break;
case "options":
[MonoTODO]
public ConnectionState State {
get {
- throw new NotImplementedException ();
+ return conState;
}
}
}
}
+ internal SqlTransaction Transaction {
+ get {
+ return trans;
+ }
+ }
+
#endregion
#region Events and Delegates
//
using System;
+using System.ComponentModel;
using System.Data;
using System.Data.Common;
//
using System;
using System.Collections;
+using System.ComponentModel;
using System.Data;
namespace System.Data.SqlClient
[MonoTODO]
public sealed class SqlError
{
+ byte theClass = 0;
+ int lineNumber = 0;
+ string message = "";
+ int number = 0;
+ string procedure = "";
+ string server = "";
+ string source = "";
+ byte state = 0;
+
+ internal SqlError(byte theClass, int lineNumber,
+ string message, int number, string procedure,
+ string server, string source, byte state) {
+ this.theClass = theClass;
+ this.lineNumber = lineNumber;
+ this.message = message;
+ this.number = number;
+ this.procedure = procedure;
+ this.server = server;
+ this.source = source;
+ this.state = state;
+ }
+
#region Properties
[MonoTODO]
+ /// <summary>
+ /// severity level of the error
+ /// </summary>
public byte Class {
get {
- throw new NotImplementedException ();
+ return theClass;
}
}
[MonoTODO]
public int LineNumber {
get {
- throw new NotImplementedException ();
+ return lineNumber;
}
}
[MonoTODO]
public string Message {
get {
- throw new NotImplementedException ();
+ return message;
}
}
[MonoTODO]
public int Number {
get {
- throw new NotImplementedException ();
+ return number;
}
}
[MonoTODO]
public string Procedure {
get {
- throw new NotImplementedException ();
+ return procedure;
}
}
[MonoTODO]
public string Server {
get {
- throw new NotImplementedException ();
+ return server;
}
}
[MonoTODO]
public string Source {
get {
- throw new NotImplementedException ();
+ return source;
}
}
[MonoTODO]
public byte State {
get {
- throw new NotImplementedException ();
+ return state;
}
}
#endregion
#region Methods
-
+
[MonoTODO]
public override string ToString ()
{
- throw new NotImplementedException ();
+ String toStr;
+ String stackTrace =
+ stackTrace = " <Stack Trace>";
+ // FIXME: generate the correct SQL error string
+ toStr = "SqlError:" + message + stackTrace;
+ return toStr;
}
- #endregion
- #region Destructors
+ internal void SetClass(byte theClass) {
+ this.theClass = theClass;
+ }
- // FIXME: do the destructor
-/*
- [MonoTODO]
- [ClassInterface(ClassInterfaceType.AutoDual)]
- ~SqlError()
- {
+ internal void SetLineNumber(int lineNumber) {
+ this.lineNumber = lineNumber;
+ }
+
+ internal void SetMessage(string message) {
+ this.message = message;
+ }
+
+ internal void SetNumber(int number) {
+ this.number = number;
+ }
+
+ internal void SetProcedure(string procedure) {
+ this.procedure = procedure;
+ }
+
+ internal void SetServer(string server) {
+ this.server = server;
+ }
+
+ internal void SetSource(string source) {
+ this.source = source;
+ }
+ internal void SetState(byte state) {
+ this.state = state;
}
-*/
#endregion
[MonoTODO]
public sealed class SqlErrorCollection : ICollection, IEnumerable
{
- #region Properties
+ private int count = 0;
+ ArrayList errorList = new ArrayList();
- [MonoTODO]
- public byte Class {
- get {
- throw new NotImplementedException ();
- }
+ internal SqlErrorCollection() {
}
- [MonoTODO]
- public int LineNumber {
- get {
- throw new NotImplementedException ();
- }
- }
-
- [MonoTODO]
- public string Message {
- get {
- throw new NotImplementedException ();
- }
- }
-
- [MonoTODO]
- public int Number {
- get {
- throw new NotImplementedException ();
- }
- }
-
- [MonoTODO]
- public string Procedure {
- get {
- throw new NotImplementedException ();
- }
- }
-
- [MonoTODO]
- public string Server {
- get {
- throw new NotImplementedException ();
- }
- }
-
- [MonoTODO]
- public string Source {
- get {
- throw new NotImplementedException ();
- }
- }
-
- [MonoTODO]
- public byte State {
- get {
- throw new NotImplementedException ();
- }
+ internal SqlErrorCollection(byte theClass, int lineNumber,
+ string message, int number, string procedure,
+ string server, string source, byte state) {
+
+ Add (theClass, lineNumber, message,
+ number, procedure,
+ server, source, state);
}
+ #region Properties
+
[MonoTODO]
public int Count {
get {
- throw new NotImplementedException ();
+ return errorList.Count;
}
}
throw new NotImplementedException ();
}
+ [MonoTODO]
+ // Index property (indexer)
+ public SqlError this[int index] {
+ get {
+ return (SqlError) errorList[index];
+ }
+ }
+
#endregion
#region Methods
}
#endregion
+ internal void Add(SqlError error) {
+ errorList.Add(error);
+ }
+
+ internal void Add(byte theClass, int lineNumber,
+ string message, int number, string procedure,
+ string server, string source, byte state) {
+
+ SqlError error = new SqlError(theClass,
+ lineNumber, message,
+ number, procedure,
+ server, source, state);
+ Add(error);
+ }
+
#region Destructors
- // FIXME: do the destructor
-/*
[MonoTODO]
- [ClassInterface(ClassInterfaceType.AutoDual)]
- ~SqlError()
+ ~SqlErrorCollection()
{
-
+ // FIXME: do the destructor - release resources
}
-*/
- #endregion
-
+ #endregion
}
}
//
using System;
using System.Data;
+using System.Runtime.Serialization;
namespace System.Data.SqlClient
{
/// </summary>
public sealed class SqlException : SystemException
{
+ private SqlErrorCollection errors = new SqlErrorCollection();
+
+ internal SqlException() {
+
+ }
+
+ internal SqlException(byte theClass, int lineNumber,
+ string message, int number, string procedure,
+ string server, string source, byte state) {
+
+ errors = new SqlErrorCollection (theClass,
+ lineNumber, message,
+ number, procedure,
+ server, source, state);
+ }
+
#region Properties
-
+
[MonoTODO]
public byte Class {
get {
- throw new NotImplementedException ();
+ if(errors.Count == 0)
+ return 0; // FIXME: throw exception here?
+ else
+ return errors[0].Class;
}
+
set {
- throw new NotImplementedException ();
+ errors[0].SetClass(value);
}
}
[MonoTODO]
public SqlErrorCollection Errors {
get {
- throw new NotImplementedException ();
+ return errors;
}
+
set {
- throw new NotImplementedException ();
+ errors = value;
}
}
[MonoTODO]
public int LineNumber {
get {
- throw new NotImplementedException ();
+ if(errors.Count == 0)
+ return 0; // FIXME: throw exception here?
+ return errors[0].LineNumber;
}
set {
- throw new NotImplementedException ();
+ errors[0].SetLineNumber(value);
}
}
[MonoTODO]
public override string Message {
get {
- throw new NotImplementedException ();
+ if(errors.Count == 0)
+ return ""; // FIXME: throw exception?
+ else {
+ String msg = "";
+ int i = 0;
+
+ for(i = 0; i < errors.Count - 1; i++) {
+ msg = msg + errors[i].Message + "\n";
+ }
+ msg = msg + errors[i];
+
+ return msg;
+ }
}
}
[MonoTODO]
public int Number {
get {
- throw new NotImplementedException ();
+ if(errors.Count == 0)
+ return 0; // FIXME: throw exception?
+ else
+ return errors[0].Number;
}
set {
- throw new NotImplementedException ();
+ errors[0].SetNumber(value);
}
}
[MonoTODO]
public string Procedure {
get {
- throw new NotImplementedException ();
+ if(errors.Count == 0)
+ return ""; // FIXME: throw exception?
+ else
+ return errors[0].Procedure;
}
set {
- throw new NotImplementedException ();
+ errors[0].SetProcedure(value);
}
}
[MonoTODO]
public string Server {
get {
- throw new NotImplementedException ();
+ if(errors.Count == 0)
+ return ""; // FIXME: throw exception?
+ else
+ return errors[0].Server;
}
set {
- throw new NotImplementedException ();
+ errors[0].SetServer(value);
}
}
[MonoTODO]
public override string Source {
get {
- throw new NotImplementedException ();
+ if(errors.Count == 0)
+ return ""; // FIXME: throw exception?
+ else
+ return errors[0].Source;
}
set {
- throw new NotImplementedException ();
+ errors[0].SetSource(value);
}
}
[MonoTODO]
public byte State {
get {
- throw new NotImplementedException ();
+ if(errors.Count == 0)
+ return 0; // FIXME: throw exception?
+ else
+ return errors[0].State;
}
set {
- throw new NotImplementedException ();
+ errors[0].SetState(value);
}
}
#endregion // Properties
+
+ #region Methods
+
+ [MonoTODO]
+ public override void GetObjectData(SerializationInfo si,
+ StreamingContext context) {
+ // FIXME: to do
+ }
+
+ // [Serializable]
+ // [ClassInterface(ClassInterfaceType.AutoDual)]
+ public override string ToString() {
+ String toStr = "";
+ for (int i = 0; i < errors.Count; i++) {
+ toStr = toStr + errors[i].ToString() + "\n";
+ }
+ return toStr;
+ }
+
+ internal void Add(byte theClass, int lineNumber,
+ string message, int number, string procedure,
+ string server, string source, byte state) {
+
+ errors.Add (theClass, lineNumber, message,
+ number, procedure,
+ server, source, state);
+ }
+
+ [MonoTODO]
+ ~SqlException() {
+ // FIXME: destructor to release resources
+ }
+
+ #endregion // Methods
}
}
{
public sealed class SqlInfoMessageEventArgs : EventArgs
{
+ [MonoTODO]
public SqlErrorCollection Errors {
get {
throw new NotImplementedException ();
}
}
+ [MonoTODO]
public string Message
{
get {
}
}
+ [MonoTODO]
public string Source {
get {
throw new NotImplementedException ();
}
}
+ [MonoTODO]
public override string ToString() {
// representation of InfoMessage event
}
+
+ [MonoTODO]
+ ~SqlInfoMessageEventArgs() {
+ // FIXME: destructor needs to release resources
+ }
}
}
--- /dev/null
+//
+// System.Data.SqlClient.SqlInfoMessageEventHandler.cs
+//
+// Author:
+// Rodrigo Moya (rodrigo@ximian.com)
+// Daniel Morgan (danmorg@sc.rr.com)
+//
+// (C) Ximian, Inc 2002
+//
+
+using System;
+using System.Data;
+
+namespace System.Data.SqlClient
+{
+ public delegate void
+ SqlInfoMessageEventHandler (object sender,
+ SqlInfoMessageEventArgs e);
+}
// (C) Ximian, Inc. 2002
//
using System;
+using System.ComponentModel;
using System.Data;
using System.Data.Common;
using System.Runtime.InteropServices;
// IDbDataParameter, IDataParameter, ICloneable
public sealed class SqlParameter : IDbDataParameter, IDataParameter
{
+ [MonoTODO]
+ public SqlParameter () {
+ // FIXME: do this
+ }
+
+ [MonoTODO]
+ public SqlParameter (string parameterName, object value) {
+ // FIXME: do this
+ }
+
+ [MonoTODO]
+ public SqlParameter(string parameterName, SqlDbType dbType) {
+ // FIXME: do this
+ }
+
+ [MonoTODO]
+ public SqlParameter(string parameterName, SqlDbType dbType,
+ int size) {
+ // FIXME: do this
+ }
+
+ [MonoTODO]
+ public SqlParameter(string parameterName, SqlDbType dbType,
+ int size, string sourceColumn) {
+ // FIXME: do this
+ }
+
+ [MonoTODO]
+ public SqlParameter(string parameterName, SqlDbType dbType,
+ int size, ParameterDirection direction,
+ bool isNullable, byte precision,
+ byte scale, string sourceColumn,
+ DataRowVersion sourceVersion, object value) {
+ // FIXME: do this
+ }
+
+
[MonoTODO]
public DbType DbType {
get {
}
}
+ [MonoTODO]
+ public int Offset {
+ get {
+ throw new NotImplementedException ();
+ }
+
+ set {
+ throw new NotImplementedException ();
+ }
+ }
+
[MonoTODO]
public string ParameterName {
get {
throw new NotImplementedException ();
}
}
+
+ [MonoTODO]
+ public SqlDbType SqlDbType {
+ get {
+ throw new NotImplementedException ();
+ }
+
+ set {
+ throw new NotImplementedException ();
+ }
+ }
[MonoTODO]
public object Value {
}
}
+ [MonoTODO]
+ public override string ToString() {
+ throw new NotImplementedException ();
+ }
}
}
//
using System;
+using System.ComponentModel;
using System.Data;
using System.Collections;
--- /dev/null
+//
+// System.Data.SqlClient.SqlRowUpdatedEventArgs.cs
+//
+// Author:
+// Rodrigo Moya (rodrigo@ximian.com)
+// Daniel Morgan (danmorg@sc.rr.com)
+//
+// (C) Ximian, Inc 2002
+//
+
+using System;
+using System.Data;
+using System.Data.Common;
+
+namespace System.Data.SqlClient {
+ public sealed class SqlRowUpdatedEventArgs : RowUpdatedEventArgs {
+
+ [MonoTODO]
+ public SqlRowUpdatedEventArgs (DataRow row,
+ IDbCommand command, StatementType statementType,
+ DataTableMapping tableMapping) {
+ // FIXME: do the constructor
+ }
+
+ [MonoTODO]
+ public new SqlCommand Command {
+ get {
+
+ }
+ }
+
+ [MonoTODO]
+ ~SqlRowUpdatedEventArgs () {
+ // FIXME: need destructor to release resources
+ }
+
+ }
+}
--- /dev/null
+//
+// System.Data.SqlClient.SqlRowUpdatedEventHandler.cs
+//
+// Author:
+// Rodrigo Moya (rodrigo@ximian.com)
+// Daniel Morgan (danmorg@sc.rr.com)
+//
+// (C) Ximian, Inc 2002
+//
+
+using System;
+using System.Data;
+
+namespace System.Data.SqlClient
+{
+ public delegate void SqlRowUpdatedEventHandler(object sender,
+ SqlRowUpdatedEventArgs e);
+}
--- /dev/null
+//
+// System.Data.SqlClient.SqlRowUpdatingEventArgs.cs
+//
+// Author:
+// Rodrigo Moya (rodrigo@ximian.com)
+// Daniel Morgan (danmorg@sc.rr.com)
+//
+// (C) Ximian, Inc 2002
+//
+
+using System;
+using System.Data;
+using System.Data.Common;
+
+namespace System.Data.SqlClient
+{
+ public sealed class SqlRowUpdatingEventArgs : RowUpdatingEventArgs
+ {
+ [MonoTODO]
+ public SqlRowUpdatingEventArgs( DataRow row,
+ IDbCommand command, StatementType statementType,
+ DataTableMapping tableMapping) {
+ // FIXME: do the constructor
+ }
+
+ [MonoTODO]
+ public new SqlCommand Command {
+ get {
+ throw new NotImplementedException ();
+ }
+
+ set {
+ throw new NotImplementedException ();
+ }
+ }
+
+ [MonoTODO]
+ ~SqlRowUpdatingEventArgs() {
+ // FIXME: create destructor to release resources
+ }
+ }
+}
--- /dev/null
+//
+// System.Data.SqlClient.SqlRowUpdatingEventHandler.cs
+//
+// Author:
+// Rodrigo Moya (rodrigo@ximian.com)
+// Daniel Morgan (danmorg@sc.rr.com)
+//
+// (C) Ximian, Inc 2002
+//
+
+using System;
+using System.Data;
+
+namespace System.Data.SqlClient
+{
+ public delegate void SqlRowUpdatingEventHandler(object sender,
+ SqlRowUpdatingEventArgs e);
+}
//
// Author:
// Rodrigo Moya (rodrigo@ximian.com)
+// Daniel Morgan (danmorg@sc.rr.com)
//
// (C) Ximian, Inc. 2002
//
+
+// use #define DEBUG_SqlTransaction if you want to spew debug messages
+// #define DEBUG_SqlTransaction
+
+
using System;
using System.Data;
using System.Data.Common;
{
#region Fields
+ private bool doingTransaction = false;
private SqlConnection conn = null;
- // How do you get/set the
- // IsolationLevel in PostgreSQL?
private IsolationLevel isolationLevel =
IsolationLevel.ReadCommitted;
- // There are two IsolationLevel's for PostgreSQL:
+ // There are only two IsolationLevel's for PostgreSQL:
// ReadCommitted and Serializable,
// but ReadCommitted is the default
[MonoTODO]
public void Commit ()
{
- IntPtr pgResult;
- ExecStatusType execStatus;
-
- pgResult = PostgresLibrary.
- PQexec (conn.PostgresConnection,
- "COMMIT");
- /* FIXME: check result and emit
- * exceptions on errors
- */
- execStatus = PostgresLibrary.
- PQresultStatus (pgResult);
-
- String cmdStatus;
- cmdStatus = PostgresLibrary.
- PQcmdStatus(pgResult);
-
- Console.WriteLine("*** Command Status: " +
- cmdStatus);
-
- PostgresLibrary.PQclear (pgResult);
+ if(doingTransaction == false)
+ throw new InvalidOperationException(
+ "Begin transaction was not " +
+ "done earlier " +
+ "thus PostgreSQL can not " +
+ "Commit transaction.");
+
+ SqlCommand cmd = new SqlCommand("COMMIT", conn);
+ cmd.ExecuteNonQuery();
+
+ doingTransaction = false;
}
[MonoTODO]
public void Rollback()
{
- IntPtr pgResult;
- ExecStatusType execStatus;
-
- pgResult = PostgresLibrary.
- PQexec (conn.PostgresConnection,
- "ROLLBACK");
- /* FIXME: check result and emit
- * exceptions on errors
- */
- execStatus = PostgresLibrary.
- PQresultStatus (pgResult);
-
- String cmdStatus;
- cmdStatus = PostgresLibrary.
- PQcmdStatus(pgResult);
-
- Console.WriteLine("*** Command Status: " +
- cmdStatus);
-
- PostgresLibrary.PQclear (pgResult);
+ if(doingTransaction == false)
+ throw new InvalidOperationException(
+ "Begin transaction was not " +
+ "done earlier " +
+ "thus PostgreSQL can not " +
+ "Rollback transaction.");
+
+ SqlCommand cmd = new SqlCommand("ROLLBACK", conn);
+ cmd.ExecuteNonQuery();
+
+ doingTransaction = false;
+ }
+
+ // For PostgreSQL, Rollback(string) will not be implemented
+ // because PostgreSQL does not support Savepoints
+ [Obsolete]
+ public void Rollback(string transactionName) {
+ // throw new NotImplementedException ();
+ Rollback();
+ }
+
+ // For PostgreSQL, Save(string) will not be implemented
+ // because PostgreSQL does not support Savepoints
+ [Obsolete]
+ public void Save (string savePointName) {
+ // throw new NotImplementedException ();
}
#endregion // Public Methods
internal void Begin()
{
- IntPtr pgResult;
- ExecStatusType execStatus;
-
- pgResult = PostgresLibrary.
- PQexec (conn.PostgresConnection,
- "BEGIN");
- /* FIXME: check result and emit
- * exceptions on errors
- */
- execStatus = PostgresLibrary.
- PQresultStatus (pgResult);
-
- String cmdStatus;
- cmdStatus = PostgresLibrary.
- PQcmdStatus(pgResult);
-
- Console.WriteLine("*** Command Status: " +
- cmdStatus);
-
- PostgresLibrary.PQclear (pgResult);
+ if(doingTransaction == true)
+ throw new InvalidOperationException(
+ "Transaction has begun " +
+ "and PostgreSQL does not " +
+ "support nested transactions.");
+
+ SqlCommand cmd = new SqlCommand("BEGIN", conn);
+ cmd.ExecuteNonQuery();
+
+ doingTransaction = true;
}
internal void SetIsolationLevel(IsolationLevel isoLevel)
{
+ String sSql = "SET TRANSACTION ISOLATION LEVEL ";
+
+ switch (isoLevel) \r
+ {
+ case IsolationLevel.ReadCommitted:
+ sSql += "READ COMMITTED";
+ break;
+
+ case IsolationLevel.Serializable:
+ sSql += "SERIALIZABLE";
+ break;
+ default:
+ // FIXME: generate exception here
+ // PostgreSQL only supports:
+ // ReadCommitted or Serializable
+ break;
+ }
+ SqlCommand cmd = new SqlCommand(sSql, conn);
+ cmd.ExecuteNonQuery();
+
this.isolationLevel = isoLevel;
}
}
}
+ internal bool DoingTransaction {
+ get {
+ return doingTransaction;
+ }
+ }
+
+ #endregion Properties
+
+ #region Destructors
+
+ // Destructors aka Finalize and Dispose
+
[MonoTODO]
public void Dispose()
{
// FIXME: need to properly release resources
+ // Dispose(true);
}
-
- #endregion // Properties
+
+ // Destructor
+ [MonoTODO]
+ // [Serializable]\r
+ // [ClassInterface(ClassInterfaceType.AutoDual)]
+ ~SqlTransaction() {
+ // FIXME: need to properly release resources
+ // Dispose(false);
+ }
+
+ #endregion // Destructors
}
}
PGRES_FATAL_ERROR
}
- // FIXME: should be sealed internal class
sealed internal class PostgresLibrary
{
#region PInvoke Functions
--- /dev/null
+//
+// System.Data.SqlClient.SqlClientPermission.cs
+//
+// Author:
+// Rodrigo Moya (rodrigo@ximian.com)
+// Daniel Morgan (danmorg@sc.rr.com)
+//
+// (C) Ximian, Inc 2002
+//
+
+using System;
+using System.Data;
+using System.Data.Common;
+
+namespace System.Data.SqlClient {
+
+ public sealed class SqlClientPermission : DBDataPermission {
+
+ [MonoTODO]
+ public SqlClientPermission() {
+ // FIXME: do constructor
+ }
+
+ [MonoTODO]
+ public SqlClientPermission(PermissionState state) {
+ // FIXME: do constructor
+ }
+
+ [MonoTODO]
+ public SqlClientPermission(PermissionState state,
+ bool allowBlankPassword) {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public override IPermission Copy() {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public override void FromXml(SecurityElement
+ securityElement) {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public override IPermission Intersect(IPermission target) {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public override bool IsSubsetOf(IPermission target) {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public override string ToString() {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public override SecurityElement ToXml() {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public override IPermission Union(IPermission target) {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ ~SqlClientPermission() {
+ // FIXME: destructor to release resources
+ }
+ }
+}
--- /dev/null
+//
+// System.Data.SqlClient.SqlClientPermissionAttribute.cs
+//
+// Author:
+// Rodrigo Moya (rodrigo@ximian.com)
+// Daniel Morgan (danmorg@sc.rr.com)
+//
+// (C) Ximian, Inc 2002
+//
+
+using System;
+using System.Data;
+using System.Data.Common;
+
+namespace System.Data.SqlClient {
+
+ [AttributeUsage(AttributeTargets.Assembly |
+ AttributeTargets.Class |
+ AttributeTargets.Struct |
+ AttributeTargets.Constructor |
+ AttributeTargets.Method)]
+ [Serializable]
+ public sealed class SqlClientPermissionAttribute :
+ DBDataPermissionAttribute {
+
+ [MonoTODO]
+ [AttributeUsage(AttributeTargets.Assembly |
+ AttributeTargets.Class |
+ AttributeTargets.Struct |
+ AttributeTargets.Constructor |
+ AttributeTargets.Method)]
+ [Serializable]
+ public SqlClientPermissionAttribute(SecurityAction action) {
+ // FIXME: do constructor
+ }
+
+ [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class
+ | AttributeTargets.Struct | AttributeTargets.Constructor |
+ AttributeTargets.Method)]
+ [Serializable]
+ public override IPermission CreatePermission() {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ ~SqlClientPermissionAttribute() {
+ // FIXME: destructor to release resources
+ }
+ }
+
+}
// (C) Ximian, Inc 2002
//
+// use #define DEBUG_SqlCommand if you want to spew debug messages
+// #define DEBUG_SqlCommand
+
using System;
using System.ComponentModel;
using System.Data;
ExecStatusType execStatus;
String rowsAffectedString;
- // FIXME: throw an
- // InvalidOperationException
- // exception if the the connection
- // does not exist or is not open
+ if(conn.State != ConnectionState.Open)
+ throw new InvalidOperationException("ConnnectionState is not Open");
// FIXME: PQexec blocks
// while PQsendQuery is non-blocking
pgResult = PostgresLibrary.
PQexec (conn.PostgresConnection, sql);
- /* FIXME: throw an SqlException exception
- * if there is a SQL Error
- */
-
- /*
- * FIXME: get status
- */
execStatus = PostgresLibrary.
PQresultStatus (pgResult);
if(execStatus == ExecStatusType.PGRES_COMMAND_OK)
{
- Console.WriteLine("*** SqlCommand Execute " +
- "got PGRES_COMMAND_OK");
rowsAffectedString = PostgresLibrary.
PQcmdTuples (pgResult);
- Console.WriteLine("*** Rows Affected: " +
- rowsAffectedString);
- // FIXME: convert string to number
+#if DEBUG_SqlCommand
+ Console.WriteLine("rowsAffectedString: " +
+ rowsAffectedString);
+#endif // DEBUG_SqlCommand
+ if(rowsAffectedString != null)
+ if(rowsAffectedString.Equals("") == false)
+ rowsAffected = int.Parse(rowsAffectedString);
}
else
{
- Console.WriteLine("*** Error: SqlCommand " +
- "did not get PGRES_COMMAND_OK");
- String statusString;
+ String errorMessage = "ExecuteNonQuery execution failure";
- statusString = PostgresLibrary.
+ errorMessage = PostgresLibrary.
PQresStatus(execStatus);
- Console.WriteLine("*** Command Status: " +
- statusString);
- String errorMessage;
- errorMessage = PostgresLibrary.\r
+ errorMessage += " " + PostgresLibrary.\r
PQresultErrorMessage(pgResult);\r
-\r
- Console.WriteLine("*** Error message: " +\r
- statusString);
+ \r
+ throw new SqlException(0, 0,
+ errorMessage, 0, "",
+ conn.DataSource, "SqlCommand", 0);\r
}
-
+#if DEBUG_SqlCommand
String cmdStatus;
cmdStatus = PostgresLibrary.
PQcmdStatus(pgResult);
Console.WriteLine("*** Command Status: " +
cmdStatus);
-
+#endif // DEBUG_SqlCommand
PostgresLibrary.PQclear (pgResult);
// FIXME: get number of rows
[MonoTODO]
public void Prepare ()
{
+ // FIXME: parameters have to be implemented for this
throw new NotImplementedException ();
}
#endregion // Properties
- #region Desctructors
-/*
+ #region Destructors
+
+ [MonoTODO]
+ public void Dispose() {
+ // FIXME: need proper way to release resources
+ // Dispose(true);
+ }
+
[MonoTODO]
- [ClassInterface(ClassInterfaceType.AutoDual)]
~SqlCommand()
{
- FIXME: need proper way to release resources
+ // FIXME: need proper way to release resources
+ // Dispose(false);
}
-*/
+
#endregion //Destructors
}
}
--- /dev/null
+//
+// System.Data.SqlClient.SqlCommandBuilder.cs
+//
+// Author:
+// Rodrigo Moya (rodrigo@ximian.com)
+// Daniel Morgan (danmorg@sc.rr.com)
+//
+// (C) Ximian, Inc 2002
+//
+
+using System;
+using System.Data;
+using System.ComponentModel;
+
+namespace System.Data.SqlClient {\r
+\r
+ /// <summary>\r
+ /// Builder of one command\r
+ /// that will be used in manipulating a table for\r
+ /// a DataSet that is assoicated with a database.\r
+ /// </summary>\r
+ public sealed class SqlCommandBuilder : Component {\r
+ \r
+ [MonoTODO]\r
+ public SqlCommandBuilder() {\r
+\r
+ }\r
+\r
+ [MonoTODO]\r
+ public SqlCommandBuilder(SqlDataAdapter adapter) {\r
+ \r
+ }\r
+\r
+ [MonoTODO]\r
+ public SqlDataAdapter DataAdapter {\r
+ get {\r
+ throw new NotImplementedException ();\r
+ }\r
+ \r
+ set{\r
+ throw new NotImplementedException ();\r
+ }\r
+ }\r
+\r
+ [MonoTODO]\r
+ public string QuotePrefix {\r
+ get {\r
+ throw new NotImplementedException ();\r
+ } \r
+ \r
+ set {\r
+ throw new NotImplementedException ();\r
+ }\r
+ }\r
+\r
+ [MonoTODO]\r
+ public string QuoteSuffix {\r
+ get {\r
+ throw new NotImplementedException ();\r
+ }\r
+ \r
+ set {\r
+ throw new NotImplementedException ();\r
+ }\r
+ }\r
+\r
+ [MonoTODO]\r
+ public static void DeriveParameters(SqlCommand command) {\r
+ throw new NotImplementedException ();\r
+ }\r
+\r
+ [MonoTODO]\r
+ public SqlCommand GetDeleteCommand() {\r
+ throw new NotImplementedException ();\r
+ }\r
+\r
+ [MonoTODO]\r
+ public SqlCommand GetInsertCommand() {\r
+ throw new NotImplementedException ();\r
+ }\r
+\r
+ [MonoTODO]\r
+ public SqlCommand GetUpdateCommand() {\r
+ throw new NotImplementedException ();\r
+ }\r
+\r
+ [MonoTODO]\r
+ public void RefreshSchema() {\r
+ throw new NotImplementedException ();\r
+ }\r
+\r
+ [MonoTODO]\r
+ protected override void Dispose(bool disposing) {\r
+ throw new NotImplementedException ();\r
+ }\r
+\r
+ [MonoTODO]\r
+ ~SqlCommandBuilder() {\r
+ // FIXME: create destructor - release resources\r
+ }\r
+ }\r
+}\r
+\r
// (C) Ximian, Inc 2002
//
-// FIXME: what is the proper way to debug messages?
-// use #define DEBUG_SqlConnection if you want to spew debug messages for
-#define DEBUG_SqlConnection
+// use #define DEBUG_SqlConnection if you want to spew debug messages
+// #define DEBUG_SqlConnection
using System;
using System.ComponentModel;
// ICloneable
public sealed class SqlConnection : IDbConnection
{
+ // FIXME: Need to implement class Component, \r
+ // and interfaces: ICloneable and IDisposable
+
#region Fields
private PGconn pgConn = IntPtr.Zero;
public SqlConnection (String connectionString)
{
SetConnectionString (connectionString);
- OpenDataSource ();
}
- #endregion
+ #endregion // Constructors
- #region Deconstructors
+ #region Destructors
+ [MonoTODO]
+ public void Dispose () {
+ // FIXME: release resources properly
+ Close ();
+ // Dispose (true);
+ }
+
// aka Finalize
-
-
- /*
- [ClassInterface(ClassInterfaceType.AutoDual)]
+ // [ClassInterface(ClassInterfaceType.AutoDual)]
+ [MonoTODO]
~SqlConnection()
{
-
+ // FIXME: this class need
+ // a destructor to release resources
+ // Also, take a look at Dispose
+ // Dispose (false);
}
- */
- #endregion // Deconstructors
+
+ #endregion // Destructors
#region Public Methods
return TransactionBegin (il); // call private method
}
+ // PostgreSQL does not support named transactions/savepoint
+ // nor nested transactions
+ [Obsolete]
+ public SqlTransaction BeginTransaction( string transactionName) {
+ return TransactionBegin (); // call private method
+ }
+
+ [Obsolete]
+ public SqlTransaction BeginTransaction(IsolationLevel iso,\r
+ string transactionName) {
+ return TransactionBegin (); // call private method
+ }
+
[MonoTODO]
public void ChangeDatabase (string databaseName)
{
OpenDataSource ();
}
- [MonoTODO]
- public void Dispose ()
- {
- // FIXME: quick hack
- Close ();
- // Dispose (true);
- }
-
- #endregion
+ #endregion // Public Methods
#region Internal Methods
private void OpenDataSource ()
{
+ if(dbname.Equals(""))
+ throw new InvalidOperationException("dbname missing");
+ else if(conState == ConnectionState.Open)
+ throw new InvalidOperationException("ConnnectionState is already Open");
+
ConnStatusType connStatus;
// FIXME: check to make sure we have
{
String errorMessage = PostgresLibrary.
PQerrorMessage (pgConn);
- // FIXME: use thie WriteLine's until
- // exceptions have been implemented
- Console.WriteLine("*** Error: " +
- "could not connect to database.");
- Console.WriteLine ("Error Message: " +
- errorMessage);
-
- // FIXME: do error checking,
- // if could not connect,
- // throw an exception:
- // InvalidOperationException - attempt
- // to connect to without specifying
- // database or server
- // SqlException - error while
- // connecting to database
-
+ errorMessage += ": Could not connect to database.";
+
+ throw new SqlException(0, 0,
+ errorMessage, 0, "",
+ host, "SqlConnection", 0);
}
-
}
private void CloseDataSource ()
connectionString);
#if DEBUG_SqlConnection
- Console.WriteLine("DEBUG_SqlConnection: " +
- "SqlConnection.pgConnectionString: " +
+ Console.WriteLine(
+ "OLE-DB Connection String [in]: " +
+ this.ConnectionString);
+ Console.WriteLine(
+ "Postgres Connection String [out]: " +
pgConnectionString);
- Console.WriteLine("DEBUG_SqlConnection: " +
- "SqlConnection.connectionString: " +
- this.connectionString);
#endif // DEBUG_SqlConnection
}
case "password":
password = parmValue;
- addParm = false;
+ // addParm = false;
break;
case "options":
[MonoTODO]
public ConnectionState State {
get {
- throw new NotImplementedException ();
+ return conState;
}
}
}
}
+ internal SqlTransaction Transaction {
+ get {
+ return trans;
+ }
+ }
+
#endregion
#region Events and Delegates
//
using System;
+using System.ComponentModel;
using System.Data;
using System.Data.Common;
//
using System;
using System.Collections;
+using System.ComponentModel;
using System.Data;
namespace System.Data.SqlClient
[MonoTODO]
public sealed class SqlError
{
+ byte theClass = 0;
+ int lineNumber = 0;
+ string message = "";
+ int number = 0;
+ string procedure = "";
+ string server = "";
+ string source = "";
+ byte state = 0;
+
+ internal SqlError(byte theClass, int lineNumber,
+ string message, int number, string procedure,
+ string server, string source, byte state) {
+ this.theClass = theClass;
+ this.lineNumber = lineNumber;
+ this.message = message;
+ this.number = number;
+ this.procedure = procedure;
+ this.server = server;
+ this.source = source;
+ this.state = state;
+ }
+
#region Properties
[MonoTODO]
+ /// <summary>
+ /// severity level of the error
+ /// </summary>
public byte Class {
get {
- throw new NotImplementedException ();
+ return theClass;
}
}
[MonoTODO]
public int LineNumber {
get {
- throw new NotImplementedException ();
+ return lineNumber;
}
}
[MonoTODO]
public string Message {
get {
- throw new NotImplementedException ();
+ return message;
}
}
[MonoTODO]
public int Number {
get {
- throw new NotImplementedException ();
+ return number;
}
}
[MonoTODO]
public string Procedure {
get {
- throw new NotImplementedException ();
+ return procedure;
}
}
[MonoTODO]
public string Server {
get {
- throw new NotImplementedException ();
+ return server;
}
}
[MonoTODO]
public string Source {
get {
- throw new NotImplementedException ();
+ return source;
}
}
[MonoTODO]
public byte State {
get {
- throw new NotImplementedException ();
+ return state;
}
}
#endregion
#region Methods
-
+
[MonoTODO]
public override string ToString ()
{
- throw new NotImplementedException ();
+ String toStr;
+ String stackTrace =
+ stackTrace = " <Stack Trace>";
+ // FIXME: generate the correct SQL error string
+ toStr = "SqlError:" + message + stackTrace;
+ return toStr;
}
- #endregion
- #region Destructors
+ internal void SetClass(byte theClass) {
+ this.theClass = theClass;
+ }
- // FIXME: do the destructor
-/*
- [MonoTODO]
- [ClassInterface(ClassInterfaceType.AutoDual)]
- ~SqlError()
- {
+ internal void SetLineNumber(int lineNumber) {
+ this.lineNumber = lineNumber;
+ }
+
+ internal void SetMessage(string message) {
+ this.message = message;
+ }
+
+ internal void SetNumber(int number) {
+ this.number = number;
+ }
+
+ internal void SetProcedure(string procedure) {
+ this.procedure = procedure;
+ }
+
+ internal void SetServer(string server) {
+ this.server = server;
+ }
+
+ internal void SetSource(string source) {
+ this.source = source;
+ }
+ internal void SetState(byte state) {
+ this.state = state;
}
-*/
#endregion
[MonoTODO]
public sealed class SqlErrorCollection : ICollection, IEnumerable
{
- #region Properties
+ private int count = 0;
+ ArrayList errorList = new ArrayList();
- [MonoTODO]
- public byte Class {
- get {
- throw new NotImplementedException ();
- }
+ internal SqlErrorCollection() {
}
- [MonoTODO]
- public int LineNumber {
- get {
- throw new NotImplementedException ();
- }
- }
-
- [MonoTODO]
- public string Message {
- get {
- throw new NotImplementedException ();
- }
- }
-
- [MonoTODO]
- public int Number {
- get {
- throw new NotImplementedException ();
- }
- }
-
- [MonoTODO]
- public string Procedure {
- get {
- throw new NotImplementedException ();
- }
- }
-
- [MonoTODO]
- public string Server {
- get {
- throw new NotImplementedException ();
- }
- }
-
- [MonoTODO]
- public string Source {
- get {
- throw new NotImplementedException ();
- }
- }
-
- [MonoTODO]
- public byte State {
- get {
- throw new NotImplementedException ();
- }
+ internal SqlErrorCollection(byte theClass, int lineNumber,
+ string message, int number, string procedure,
+ string server, string source, byte state) {
+
+ Add (theClass, lineNumber, message,
+ number, procedure,
+ server, source, state);
}
+ #region Properties
+
[MonoTODO]
public int Count {
get {
- throw new NotImplementedException ();
+ return errorList.Count;
}
}
throw new NotImplementedException ();
}
+ [MonoTODO]
+ // Index property (indexer)
+ public SqlError this[int index] {
+ get {
+ return (SqlError) errorList[index];
+ }
+ }
+
#endregion
#region Methods
}
#endregion
+ internal void Add(SqlError error) {
+ errorList.Add(error);
+ }
+
+ internal void Add(byte theClass, int lineNumber,
+ string message, int number, string procedure,
+ string server, string source, byte state) {
+
+ SqlError error = new SqlError(theClass,
+ lineNumber, message,
+ number, procedure,
+ server, source, state);
+ Add(error);
+ }
+
#region Destructors
- // FIXME: do the destructor
-/*
[MonoTODO]
- [ClassInterface(ClassInterfaceType.AutoDual)]
- ~SqlError()
+ ~SqlErrorCollection()
{
-
+ // FIXME: do the destructor - release resources
}
-*/
- #endregion
-
+ #endregion
}
}
//
using System;
using System.Data;
+using System.Runtime.Serialization;
namespace System.Data.SqlClient
{
/// </summary>
public sealed class SqlException : SystemException
{
+ private SqlErrorCollection errors = new SqlErrorCollection();
+
+ internal SqlException() {
+
+ }
+
+ internal SqlException(byte theClass, int lineNumber,
+ string message, int number, string procedure,
+ string server, string source, byte state) {
+
+ errors = new SqlErrorCollection (theClass,
+ lineNumber, message,
+ number, procedure,
+ server, source, state);
+ }
+
#region Properties
-
+
[MonoTODO]
public byte Class {
get {
- throw new NotImplementedException ();
+ if(errors.Count == 0)
+ return 0; // FIXME: throw exception here?
+ else
+ return errors[0].Class;
}
+
set {
- throw new NotImplementedException ();
+ errors[0].SetClass(value);
}
}
[MonoTODO]
public SqlErrorCollection Errors {
get {
- throw new NotImplementedException ();
+ return errors;
}
+
set {
- throw new NotImplementedException ();
+ errors = value;
}
}
[MonoTODO]
public int LineNumber {
get {
- throw new NotImplementedException ();
+ if(errors.Count == 0)
+ return 0; // FIXME: throw exception here?
+ return errors[0].LineNumber;
}
set {
- throw new NotImplementedException ();
+ errors[0].SetLineNumber(value);
}
}
[MonoTODO]
public override string Message {
get {
- throw new NotImplementedException ();
+ if(errors.Count == 0)
+ return ""; // FIXME: throw exception?
+ else {
+ String msg = "";
+ int i = 0;
+
+ for(i = 0; i < errors.Count - 1; i++) {
+ msg = msg + errors[i].Message + "\n";
+ }
+ msg = msg + errors[i];
+
+ return msg;
+ }
}
}
[MonoTODO]
public int Number {
get {
- throw new NotImplementedException ();
+ if(errors.Count == 0)
+ return 0; // FIXME: throw exception?
+ else
+ return errors[0].Number;
}
set {
- throw new NotImplementedException ();
+ errors[0].SetNumber(value);
}
}
[MonoTODO]
public string Procedure {
get {
- throw new NotImplementedException ();
+ if(errors.Count == 0)
+ return ""; // FIXME: throw exception?
+ else
+ return errors[0].Procedure;
}
set {
- throw new NotImplementedException ();
+ errors[0].SetProcedure(value);
}
}
[MonoTODO]
public string Server {
get {
- throw new NotImplementedException ();
+ if(errors.Count == 0)
+ return ""; // FIXME: throw exception?
+ else
+ return errors[0].Server;
}
set {
- throw new NotImplementedException ();
+ errors[0].SetServer(value);
}
}
[MonoTODO]
public override string Source {
get {
- throw new NotImplementedException ();
+ if(errors.Count == 0)
+ return ""; // FIXME: throw exception?
+ else
+ return errors[0].Source;
}
set {
- throw new NotImplementedException ();
+ errors[0].SetSource(value);
}
}
[MonoTODO]
public byte State {
get {
- throw new NotImplementedException ();
+ if(errors.Count == 0)
+ return 0; // FIXME: throw exception?
+ else
+ return errors[0].State;
}
set {
- throw new NotImplementedException ();
+ errors[0].SetState(value);
}
}
#endregion // Properties
+
+ #region Methods
+
+ [MonoTODO]
+ public override void GetObjectData(SerializationInfo si,
+ StreamingContext context) {
+ // FIXME: to do
+ }
+
+ // [Serializable]
+ // [ClassInterface(ClassInterfaceType.AutoDual)]
+ public override string ToString() {
+ String toStr = "";
+ for (int i = 0; i < errors.Count; i++) {
+ toStr = toStr + errors[i].ToString() + "\n";
+ }
+ return toStr;
+ }
+
+ internal void Add(byte theClass, int lineNumber,
+ string message, int number, string procedure,
+ string server, string source, byte state) {
+
+ errors.Add (theClass, lineNumber, message,
+ number, procedure,
+ server, source, state);
+ }
+
+ [MonoTODO]
+ ~SqlException() {
+ // FIXME: destructor to release resources
+ }
+
+ #endregion // Methods
}
}
{
public sealed class SqlInfoMessageEventArgs : EventArgs
{
+ [MonoTODO]
public SqlErrorCollection Errors {
get {
throw new NotImplementedException ();
}
}
+ [MonoTODO]
public string Message
{
get {
}
}
+ [MonoTODO]
public string Source {
get {
throw new NotImplementedException ();
}
}
+ [MonoTODO]
public override string ToString() {
// representation of InfoMessage event
}
+
+ [MonoTODO]
+ ~SqlInfoMessageEventArgs() {
+ // FIXME: destructor needs to release resources
+ }
}
}
--- /dev/null
+//
+// System.Data.SqlClient.SqlInfoMessageEventHandler.cs
+//
+// Author:
+// Rodrigo Moya (rodrigo@ximian.com)
+// Daniel Morgan (danmorg@sc.rr.com)
+//
+// (C) Ximian, Inc 2002
+//
+
+using System;
+using System.Data;
+
+namespace System.Data.SqlClient
+{
+ public delegate void
+ SqlInfoMessageEventHandler (object sender,
+ SqlInfoMessageEventArgs e);
+}
// (C) Ximian, Inc. 2002
//
using System;
+using System.ComponentModel;
using System.Data;
using System.Data.Common;
using System.Runtime.InteropServices;
// IDbDataParameter, IDataParameter, ICloneable
public sealed class SqlParameter : IDbDataParameter, IDataParameter
{
+ [MonoTODO]
+ public SqlParameter () {
+ // FIXME: do this
+ }
+
+ [MonoTODO]
+ public SqlParameter (string parameterName, object value) {
+ // FIXME: do this
+ }
+
+ [MonoTODO]
+ public SqlParameter(string parameterName, SqlDbType dbType) {
+ // FIXME: do this
+ }
+
+ [MonoTODO]
+ public SqlParameter(string parameterName, SqlDbType dbType,
+ int size) {
+ // FIXME: do this
+ }
+
+ [MonoTODO]
+ public SqlParameter(string parameterName, SqlDbType dbType,
+ int size, string sourceColumn) {
+ // FIXME: do this
+ }
+
+ [MonoTODO]
+ public SqlParameter(string parameterName, SqlDbType dbType,
+ int size, ParameterDirection direction,
+ bool isNullable, byte precision,
+ byte scale, string sourceColumn,
+ DataRowVersion sourceVersion, object value) {
+ // FIXME: do this
+ }
+
+
[MonoTODO]
public DbType DbType {
get {
}
}
+ [MonoTODO]
+ public int Offset {
+ get {
+ throw new NotImplementedException ();
+ }
+
+ set {
+ throw new NotImplementedException ();
+ }
+ }
+
[MonoTODO]
public string ParameterName {
get {
throw new NotImplementedException ();
}
}
+
+ [MonoTODO]
+ public SqlDbType SqlDbType {
+ get {
+ throw new NotImplementedException ();
+ }
+
+ set {
+ throw new NotImplementedException ();
+ }
+ }
[MonoTODO]
public object Value {
}
}
+ [MonoTODO]
+ public override string ToString() {
+ throw new NotImplementedException ();
+ }
}
}
//
using System;
+using System.ComponentModel;
using System.Data;
using System.Collections;
--- /dev/null
+//
+// System.Data.SqlClient.SqlRowUpdatedEventArgs.cs
+//
+// Author:
+// Rodrigo Moya (rodrigo@ximian.com)
+// Daniel Morgan (danmorg@sc.rr.com)
+//
+// (C) Ximian, Inc 2002
+//
+
+using System;
+using System.Data;
+using System.Data.Common;
+
+namespace System.Data.SqlClient {
+ public sealed class SqlRowUpdatedEventArgs : RowUpdatedEventArgs {
+
+ [MonoTODO]
+ public SqlRowUpdatedEventArgs (DataRow row,
+ IDbCommand command, StatementType statementType,
+ DataTableMapping tableMapping) {
+ // FIXME: do the constructor
+ }
+
+ [MonoTODO]
+ public new SqlCommand Command {
+ get {
+
+ }
+ }
+
+ [MonoTODO]
+ ~SqlRowUpdatedEventArgs () {
+ // FIXME: need destructor to release resources
+ }
+
+ }
+}
--- /dev/null
+//
+// System.Data.SqlClient.SqlRowUpdatedEventHandler.cs
+//
+// Author:
+// Rodrigo Moya (rodrigo@ximian.com)
+// Daniel Morgan (danmorg@sc.rr.com)
+//
+// (C) Ximian, Inc 2002
+//
+
+using System;
+using System.Data;
+
+namespace System.Data.SqlClient
+{
+ public delegate void SqlRowUpdatedEventHandler(object sender,
+ SqlRowUpdatedEventArgs e);
+}
--- /dev/null
+//
+// System.Data.SqlClient.SqlRowUpdatingEventArgs.cs
+//
+// Author:
+// Rodrigo Moya (rodrigo@ximian.com)
+// Daniel Morgan (danmorg@sc.rr.com)
+//
+// (C) Ximian, Inc 2002
+//
+
+using System;
+using System.Data;
+using System.Data.Common;
+
+namespace System.Data.SqlClient
+{
+ public sealed class SqlRowUpdatingEventArgs : RowUpdatingEventArgs
+ {
+ [MonoTODO]
+ public SqlRowUpdatingEventArgs( DataRow row,
+ IDbCommand command, StatementType statementType,
+ DataTableMapping tableMapping) {
+ // FIXME: do the constructor
+ }
+
+ [MonoTODO]
+ public new SqlCommand Command {
+ get {
+ throw new NotImplementedException ();
+ }
+
+ set {
+ throw new NotImplementedException ();
+ }
+ }
+
+ [MonoTODO]
+ ~SqlRowUpdatingEventArgs() {
+ // FIXME: create destructor to release resources
+ }
+ }
+}
--- /dev/null
+//
+// System.Data.SqlClient.SqlRowUpdatingEventHandler.cs
+//
+// Author:
+// Rodrigo Moya (rodrigo@ximian.com)
+// Daniel Morgan (danmorg@sc.rr.com)
+//
+// (C) Ximian, Inc 2002
+//
+
+using System;
+using System.Data;
+
+namespace System.Data.SqlClient
+{
+ public delegate void SqlRowUpdatingEventHandler(object sender,
+ SqlRowUpdatingEventArgs e);
+}
//
// Author:
// Rodrigo Moya (rodrigo@ximian.com)
+// Daniel Morgan (danmorg@sc.rr.com)
//
// (C) Ximian, Inc. 2002
//
+
+// use #define DEBUG_SqlTransaction if you want to spew debug messages
+// #define DEBUG_SqlTransaction
+
+
using System;
using System.Data;
using System.Data.Common;
{
#region Fields
+ private bool doingTransaction = false;
private SqlConnection conn = null;
- // How do you get/set the
- // IsolationLevel in PostgreSQL?
private IsolationLevel isolationLevel =
IsolationLevel.ReadCommitted;
- // There are two IsolationLevel's for PostgreSQL:
+ // There are only two IsolationLevel's for PostgreSQL:
// ReadCommitted and Serializable,
// but ReadCommitted is the default
[MonoTODO]
public void Commit ()
{
- IntPtr pgResult;
- ExecStatusType execStatus;
-
- pgResult = PostgresLibrary.
- PQexec (conn.PostgresConnection,
- "COMMIT");
- /* FIXME: check result and emit
- * exceptions on errors
- */
- execStatus = PostgresLibrary.
- PQresultStatus (pgResult);
-
- String cmdStatus;
- cmdStatus = PostgresLibrary.
- PQcmdStatus(pgResult);
-
- Console.WriteLine("*** Command Status: " +
- cmdStatus);
-
- PostgresLibrary.PQclear (pgResult);
+ if(doingTransaction == false)
+ throw new InvalidOperationException(
+ "Begin transaction was not " +
+ "done earlier " +
+ "thus PostgreSQL can not " +
+ "Commit transaction.");
+
+ SqlCommand cmd = new SqlCommand("COMMIT", conn);
+ cmd.ExecuteNonQuery();
+
+ doingTransaction = false;
}
[MonoTODO]
public void Rollback()
{
- IntPtr pgResult;
- ExecStatusType execStatus;
-
- pgResult = PostgresLibrary.
- PQexec (conn.PostgresConnection,
- "ROLLBACK");
- /* FIXME: check result and emit
- * exceptions on errors
- */
- execStatus = PostgresLibrary.
- PQresultStatus (pgResult);
-
- String cmdStatus;
- cmdStatus = PostgresLibrary.
- PQcmdStatus(pgResult);
-
- Console.WriteLine("*** Command Status: " +
- cmdStatus);
-
- PostgresLibrary.PQclear (pgResult);
+ if(doingTransaction == false)
+ throw new InvalidOperationException(
+ "Begin transaction was not " +
+ "done earlier " +
+ "thus PostgreSQL can not " +
+ "Rollback transaction.");
+
+ SqlCommand cmd = new SqlCommand("ROLLBACK", conn);
+ cmd.ExecuteNonQuery();
+
+ doingTransaction = false;
+ }
+
+ // For PostgreSQL, Rollback(string) will not be implemented
+ // because PostgreSQL does not support Savepoints
+ [Obsolete]
+ public void Rollback(string transactionName) {
+ // throw new NotImplementedException ();
+ Rollback();
+ }
+
+ // For PostgreSQL, Save(string) will not be implemented
+ // because PostgreSQL does not support Savepoints
+ [Obsolete]
+ public void Save (string savePointName) {
+ // throw new NotImplementedException ();
}
#endregion // Public Methods
internal void Begin()
{
- IntPtr pgResult;
- ExecStatusType execStatus;
-
- pgResult = PostgresLibrary.
- PQexec (conn.PostgresConnection,
- "BEGIN");
- /* FIXME: check result and emit
- * exceptions on errors
- */
- execStatus = PostgresLibrary.
- PQresultStatus (pgResult);
-
- String cmdStatus;
- cmdStatus = PostgresLibrary.
- PQcmdStatus(pgResult);
-
- Console.WriteLine("*** Command Status: " +
- cmdStatus);
-
- PostgresLibrary.PQclear (pgResult);
+ if(doingTransaction == true)
+ throw new InvalidOperationException(
+ "Transaction has begun " +
+ "and PostgreSQL does not " +
+ "support nested transactions.");
+
+ SqlCommand cmd = new SqlCommand("BEGIN", conn);
+ cmd.ExecuteNonQuery();
+
+ doingTransaction = true;
}
internal void SetIsolationLevel(IsolationLevel isoLevel)
{
+ String sSql = "SET TRANSACTION ISOLATION LEVEL ";
+
+ switch (isoLevel) \r
+ {
+ case IsolationLevel.ReadCommitted:
+ sSql += "READ COMMITTED";
+ break;
+
+ case IsolationLevel.Serializable:
+ sSql += "SERIALIZABLE";
+ break;
+ default:
+ // FIXME: generate exception here
+ // PostgreSQL only supports:
+ // ReadCommitted or Serializable
+ break;
+ }
+ SqlCommand cmd = new SqlCommand(sSql, conn);
+ cmd.ExecuteNonQuery();
+
this.isolationLevel = isoLevel;
}
}
}
+ internal bool DoingTransaction {
+ get {
+ return doingTransaction;
+ }
+ }
+
+ #endregion Properties
+
+ #region Destructors
+
+ // Destructors aka Finalize and Dispose
+
[MonoTODO]
public void Dispose()
{
// FIXME: need to properly release resources
+ // Dispose(true);
}
-
- #endregion // Properties
+
+ // Destructor
+ [MonoTODO]
+ // [Serializable]\r
+ // [ClassInterface(ClassInterfaceType.AutoDual)]
+ ~SqlTransaction() {
+ // FIXME: need to properly release resources
+ // Dispose(false);
+ }
+
+ #endregion // Destructors
}
}
PGRES_FATAL_ERROR
}
- // FIXME: should be sealed internal class
sealed internal class PostgresLibrary
{
#region PInvoke Functions
+2002-04-20 Daniel Morgan <danmorg@sc.rr.com>
+
+* System.Data.OleDb: added directory - for OleDb database
+provider classes
+
+* System.Data.SqlClient/SqlClientPermission.cs
+* System.Data.SqlClient/SqlClientPermissionAttribute.cs
+* System.Data.SqlClient/SqlCommandBuilder.cs
+* System.Data.SqlClient/SqlInfoMessageEventHandler.cs
+* System.Data.SqlClient/SqlRowUpdatedEventArgs.cs
+* System.Data.SqlClient/SqlRowUpdatedEventHandler.cs
+* System.Data.SqlClient/SqlRowUpdatingEventArgs.cs
+* System.Data.SqlClient/SqlRowUpdatingEventHandler.cs
+* Test/TestSqlException.cs
+* Test/TestSqlIsolationLevel.cs: added - more tests
+
+* System.Data.build: modified - added new files - excludes these too
+
+* System.Data.SqlClient/PostgresLibrary.cs - modified - comment
+
+* System.Data.SqlClient/SqlConnection.cs
+* System.Data.SqlClient/SqlCommand.cs
+* System.Data.SqlClient/SqlTransaction.cs
+* System.Data.SqlClient/SqlException.cs
+* System.Data.SqlClient/SqlErrorCollection.cs
+* System.Data.SqlClient/SqlError.cs: modified - transaction and
+ exception/error handling. SqlConnection(connectionString)
+ constructor should not automatically connect.
+
+* System.Data.SqlClient/SqlDataReader.cs
+* System.Data.SqlClient/SqlDataAdapter.cs
+* System.Data.SqlClient/SqlParameter.cs
+* System.Data.SqlClient/SqlParameterCollection.cs: modified -
+added using System.ComponentModel;
+
+* Test/TestSqlInsert.cs: modified - to use transaction
+
2002-04-17 Rodrigo Moya <rodrigo@ximian.com>
* System.Data/DataRow.cs: new skeletons.
PGRES_FATAL_ERROR
}
- // FIXME: should be sealed internal class
sealed internal class PostgresLibrary
{
#region PInvoke Functions
--- /dev/null
+//
+// System.Data.SqlClient.SqlClientPermission.cs
+//
+// Author:
+// Rodrigo Moya (rodrigo@ximian.com)
+// Daniel Morgan (danmorg@sc.rr.com)
+//
+// (C) Ximian, Inc 2002
+//
+
+using System;
+using System.Data;
+using System.Data.Common;
+
+namespace System.Data.SqlClient {
+
+ public sealed class SqlClientPermission : DBDataPermission {
+
+ [MonoTODO]
+ public SqlClientPermission() {
+ // FIXME: do constructor
+ }
+
+ [MonoTODO]
+ public SqlClientPermission(PermissionState state) {
+ // FIXME: do constructor
+ }
+
+ [MonoTODO]
+ public SqlClientPermission(PermissionState state,
+ bool allowBlankPassword) {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public override IPermission Copy() {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public override void FromXml(SecurityElement
+ securityElement) {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public override IPermission Intersect(IPermission target) {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public override bool IsSubsetOf(IPermission target) {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public override string ToString() {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public override SecurityElement ToXml() {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public override IPermission Union(IPermission target) {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ ~SqlClientPermission() {
+ // FIXME: destructor to release resources
+ }
+ }
+}
--- /dev/null
+//
+// System.Data.SqlClient.SqlClientPermissionAttribute.cs
+//
+// Author:
+// Rodrigo Moya (rodrigo@ximian.com)
+// Daniel Morgan (danmorg@sc.rr.com)
+//
+// (C) Ximian, Inc 2002
+//
+
+using System;
+using System.Data;
+using System.Data.Common;
+
+namespace System.Data.SqlClient {
+
+ [AttributeUsage(AttributeTargets.Assembly |
+ AttributeTargets.Class |
+ AttributeTargets.Struct |
+ AttributeTargets.Constructor |
+ AttributeTargets.Method)]
+ [Serializable]
+ public sealed class SqlClientPermissionAttribute :
+ DBDataPermissionAttribute {
+
+ [MonoTODO]
+ [AttributeUsage(AttributeTargets.Assembly |
+ AttributeTargets.Class |
+ AttributeTargets.Struct |
+ AttributeTargets.Constructor |
+ AttributeTargets.Method)]
+ [Serializable]
+ public SqlClientPermissionAttribute(SecurityAction action) {
+ // FIXME: do constructor
+ }
+
+ [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class
+ | AttributeTargets.Struct | AttributeTargets.Constructor |
+ AttributeTargets.Method)]
+ [Serializable]
+ public override IPermission CreatePermission() {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ ~SqlClientPermissionAttribute() {
+ // FIXME: destructor to release resources
+ }
+ }
+
+}
// (C) Ximian, Inc 2002
//
+// use #define DEBUG_SqlCommand if you want to spew debug messages
+// #define DEBUG_SqlCommand
+
using System;
using System.ComponentModel;
using System.Data;
ExecStatusType execStatus;
String rowsAffectedString;
- // FIXME: throw an
- // InvalidOperationException
- // exception if the the connection
- // does not exist or is not open
+ if(conn.State != ConnectionState.Open)
+ throw new InvalidOperationException("ConnnectionState is not Open");
// FIXME: PQexec blocks
// while PQsendQuery is non-blocking
pgResult = PostgresLibrary.
PQexec (conn.PostgresConnection, sql);
- /* FIXME: throw an SqlException exception
- * if there is a SQL Error
- */
-
- /*
- * FIXME: get status
- */
execStatus = PostgresLibrary.
PQresultStatus (pgResult);
if(execStatus == ExecStatusType.PGRES_COMMAND_OK)
{
- Console.WriteLine("*** SqlCommand Execute " +
- "got PGRES_COMMAND_OK");
rowsAffectedString = PostgresLibrary.
PQcmdTuples (pgResult);
- Console.WriteLine("*** Rows Affected: " +
- rowsAffectedString);
- // FIXME: convert string to number
+#if DEBUG_SqlCommand
+ Console.WriteLine("rowsAffectedString: " +
+ rowsAffectedString);
+#endif // DEBUG_SqlCommand
+ if(rowsAffectedString != null)
+ if(rowsAffectedString.Equals("") == false)
+ rowsAffected = int.Parse(rowsAffectedString);
}
else
{
- Console.WriteLine("*** Error: SqlCommand " +
- "did not get PGRES_COMMAND_OK");
- String statusString;
+ String errorMessage = "ExecuteNonQuery execution failure";
- statusString = PostgresLibrary.
+ errorMessage = PostgresLibrary.
PQresStatus(execStatus);
- Console.WriteLine("*** Command Status: " +
- statusString);
- String errorMessage;
- errorMessage = PostgresLibrary.\r
+ errorMessage += " " + PostgresLibrary.\r
PQresultErrorMessage(pgResult);\r
-\r
- Console.WriteLine("*** Error message: " +\r
- statusString);
+ \r
+ throw new SqlException(0, 0,
+ errorMessage, 0, "",
+ conn.DataSource, "SqlCommand", 0);\r
}
-
+#if DEBUG_SqlCommand
String cmdStatus;
cmdStatus = PostgresLibrary.
PQcmdStatus(pgResult);
Console.WriteLine("*** Command Status: " +
cmdStatus);
-
+#endif // DEBUG_SqlCommand
PostgresLibrary.PQclear (pgResult);
// FIXME: get number of rows
[MonoTODO]
public void Prepare ()
{
+ // FIXME: parameters have to be implemented for this
throw new NotImplementedException ();
}
#endregion // Properties
- #region Desctructors
-/*
+ #region Destructors
+
+ [MonoTODO]
+ public void Dispose() {
+ // FIXME: need proper way to release resources
+ // Dispose(true);
+ }
+
[MonoTODO]
- [ClassInterface(ClassInterfaceType.AutoDual)]
~SqlCommand()
{
- FIXME: need proper way to release resources
+ // FIXME: need proper way to release resources
+ // Dispose(false);
}
-*/
+
#endregion //Destructors
}
}
--- /dev/null
+//
+// System.Data.SqlClient.SqlCommandBuilder.cs
+//
+// Author:
+// Rodrigo Moya (rodrigo@ximian.com)
+// Daniel Morgan (danmorg@sc.rr.com)
+//
+// (C) Ximian, Inc 2002
+//
+
+using System;
+using System.Data;
+using System.ComponentModel;
+
+namespace System.Data.SqlClient {\r
+\r
+ /// <summary>\r
+ /// Builder of one command\r
+ /// that will be used in manipulating a table for\r
+ /// a DataSet that is assoicated with a database.\r
+ /// </summary>\r
+ public sealed class SqlCommandBuilder : Component {\r
+ \r
+ [MonoTODO]\r
+ public SqlCommandBuilder() {\r
+\r
+ }\r
+\r
+ [MonoTODO]\r
+ public SqlCommandBuilder(SqlDataAdapter adapter) {\r
+ \r
+ }\r
+\r
+ [MonoTODO]\r
+ public SqlDataAdapter DataAdapter {\r
+ get {\r
+ throw new NotImplementedException ();\r
+ }\r
+ \r
+ set{\r
+ throw new NotImplementedException ();\r
+ }\r
+ }\r
+\r
+ [MonoTODO]\r
+ public string QuotePrefix {\r
+ get {\r
+ throw new NotImplementedException ();\r
+ } \r
+ \r
+ set {\r
+ throw new NotImplementedException ();\r
+ }\r
+ }\r
+\r
+ [MonoTODO]\r
+ public string QuoteSuffix {\r
+ get {\r
+ throw new NotImplementedException ();\r
+ }\r
+ \r
+ set {\r
+ throw new NotImplementedException ();\r
+ }\r
+ }\r
+\r
+ [MonoTODO]\r
+ public static void DeriveParameters(SqlCommand command) {\r
+ throw new NotImplementedException ();\r
+ }\r
+\r
+ [MonoTODO]\r
+ public SqlCommand GetDeleteCommand() {\r
+ throw new NotImplementedException ();\r
+ }\r
+\r
+ [MonoTODO]\r
+ public SqlCommand GetInsertCommand() {\r
+ throw new NotImplementedException ();\r
+ }\r
+\r
+ [MonoTODO]\r
+ public SqlCommand GetUpdateCommand() {\r
+ throw new NotImplementedException ();\r
+ }\r
+\r
+ [MonoTODO]\r
+ public void RefreshSchema() {\r
+ throw new NotImplementedException ();\r
+ }\r
+\r
+ [MonoTODO]\r
+ protected override void Dispose(bool disposing) {\r
+ throw new NotImplementedException ();\r
+ }\r
+\r
+ [MonoTODO]\r
+ ~SqlCommandBuilder() {\r
+ // FIXME: create destructor - release resources\r
+ }\r
+ }\r
+}\r
+\r
// (C) Ximian, Inc 2002
//
-// FIXME: what is the proper way to debug messages?
-// use #define DEBUG_SqlConnection if you want to spew debug messages for
-#define DEBUG_SqlConnection
+// use #define DEBUG_SqlConnection if you want to spew debug messages
+// #define DEBUG_SqlConnection
using System;
using System.ComponentModel;
// ICloneable
public sealed class SqlConnection : IDbConnection
{
+ // FIXME: Need to implement class Component, \r
+ // and interfaces: ICloneable and IDisposable
+
#region Fields
private PGconn pgConn = IntPtr.Zero;
public SqlConnection (String connectionString)
{
SetConnectionString (connectionString);
- OpenDataSource ();
}
- #endregion
+ #endregion // Constructors
- #region Deconstructors
+ #region Destructors
+ [MonoTODO]
+ public void Dispose () {
+ // FIXME: release resources properly
+ Close ();
+ // Dispose (true);
+ }
+
// aka Finalize
-
-
- /*
- [ClassInterface(ClassInterfaceType.AutoDual)]
+ // [ClassInterface(ClassInterfaceType.AutoDual)]
+ [MonoTODO]
~SqlConnection()
{
-
+ // FIXME: this class need
+ // a destructor to release resources
+ // Also, take a look at Dispose
+ // Dispose (false);
}
- */
- #endregion // Deconstructors
+
+ #endregion // Destructors
#region Public Methods
return TransactionBegin (il); // call private method
}
+ // PostgreSQL does not support named transactions/savepoint
+ // nor nested transactions
+ [Obsolete]
+ public SqlTransaction BeginTransaction( string transactionName) {
+ return TransactionBegin (); // call private method
+ }
+
+ [Obsolete]
+ public SqlTransaction BeginTransaction(IsolationLevel iso,\r
+ string transactionName) {
+ return TransactionBegin (); // call private method
+ }
+
[MonoTODO]
public void ChangeDatabase (string databaseName)
{
OpenDataSource ();
}
- [MonoTODO]
- public void Dispose ()
- {
- // FIXME: quick hack
- Close ();
- // Dispose (true);
- }
-
- #endregion
+ #endregion // Public Methods
#region Internal Methods
private void OpenDataSource ()
{
+ if(dbname.Equals(""))
+ throw new InvalidOperationException("dbname missing");
+ else if(conState == ConnectionState.Open)
+ throw new InvalidOperationException("ConnnectionState is already Open");
+
ConnStatusType connStatus;
// FIXME: check to make sure we have
{
String errorMessage = PostgresLibrary.
PQerrorMessage (pgConn);
- // FIXME: use thie WriteLine's until
- // exceptions have been implemented
- Console.WriteLine("*** Error: " +
- "could not connect to database.");
- Console.WriteLine ("Error Message: " +
- errorMessage);
-
- // FIXME: do error checking,
- // if could not connect,
- // throw an exception:
- // InvalidOperationException - attempt
- // to connect to without specifying
- // database or server
- // SqlException - error while
- // connecting to database
-
+ errorMessage += ": Could not connect to database.";
+
+ throw new SqlException(0, 0,
+ errorMessage, 0, "",
+ host, "SqlConnection", 0);
}
-
}
private void CloseDataSource ()
connectionString);
#if DEBUG_SqlConnection
- Console.WriteLine("DEBUG_SqlConnection: " +
- "SqlConnection.pgConnectionString: " +
+ Console.WriteLine(
+ "OLE-DB Connection String [in]: " +
+ this.ConnectionString);
+ Console.WriteLine(
+ "Postgres Connection String [out]: " +
pgConnectionString);
- Console.WriteLine("DEBUG_SqlConnection: " +
- "SqlConnection.connectionString: " +
- this.connectionString);
#endif // DEBUG_SqlConnection
}
case "password":
password = parmValue;
- addParm = false;
+ // addParm = false;
break;
case "options":
[MonoTODO]
public ConnectionState State {
get {
- throw new NotImplementedException ();
+ return conState;
}
}
}
}
+ internal SqlTransaction Transaction {
+ get {
+ return trans;
+ }
+ }
+
#endregion
#region Events and Delegates
//
using System;
+using System.ComponentModel;
using System.Data;
using System.Data.Common;
//
using System;
using System.Collections;
+using System.ComponentModel;
using System.Data;
namespace System.Data.SqlClient
[MonoTODO]
public sealed class SqlError
{
+ byte theClass = 0;
+ int lineNumber = 0;
+ string message = "";
+ int number = 0;
+ string procedure = "";
+ string server = "";
+ string source = "";
+ byte state = 0;
+
+ internal SqlError(byte theClass, int lineNumber,
+ string message, int number, string procedure,
+ string server, string source, byte state) {
+ this.theClass = theClass;
+ this.lineNumber = lineNumber;
+ this.message = message;
+ this.number = number;
+ this.procedure = procedure;
+ this.server = server;
+ this.source = source;
+ this.state = state;
+ }
+
#region Properties
[MonoTODO]
+ /// <summary>
+ /// severity level of the error
+ /// </summary>
public byte Class {
get {
- throw new NotImplementedException ();
+ return theClass;
}
}
[MonoTODO]
public int LineNumber {
get {
- throw new NotImplementedException ();
+ return lineNumber;
}
}
[MonoTODO]
public string Message {
get {
- throw new NotImplementedException ();
+ return message;
}
}
[MonoTODO]
public int Number {
get {
- throw new NotImplementedException ();
+ return number;
}
}
[MonoTODO]
public string Procedure {
get {
- throw new NotImplementedException ();
+ return procedure;
}
}
[MonoTODO]
public string Server {
get {
- throw new NotImplementedException ();
+ return server;
}
}
[MonoTODO]
public string Source {
get {
- throw new NotImplementedException ();
+ return source;
}
}
[MonoTODO]
public byte State {
get {
- throw new NotImplementedException ();
+ return state;
}
}
#endregion
#region Methods
-
+
[MonoTODO]
public override string ToString ()
{
- throw new NotImplementedException ();
+ String toStr;
+ String stackTrace =
+ stackTrace = " <Stack Trace>";
+ // FIXME: generate the correct SQL error string
+ toStr = "SqlError:" + message + stackTrace;
+ return toStr;
}
- #endregion
- #region Destructors
+ internal void SetClass(byte theClass) {
+ this.theClass = theClass;
+ }
- // FIXME: do the destructor
-/*
- [MonoTODO]
- [ClassInterface(ClassInterfaceType.AutoDual)]
- ~SqlError()
- {
+ internal void SetLineNumber(int lineNumber) {
+ this.lineNumber = lineNumber;
+ }
+
+ internal void SetMessage(string message) {
+ this.message = message;
+ }
+
+ internal void SetNumber(int number) {
+ this.number = number;
+ }
+
+ internal void SetProcedure(string procedure) {
+ this.procedure = procedure;
+ }
+
+ internal void SetServer(string server) {
+ this.server = server;
+ }
+
+ internal void SetSource(string source) {
+ this.source = source;
+ }
+ internal void SetState(byte state) {
+ this.state = state;
}
-*/
#endregion
[MonoTODO]
public sealed class SqlErrorCollection : ICollection, IEnumerable
{
- #region Properties
+ private int count = 0;
+ ArrayList errorList = new ArrayList();
- [MonoTODO]
- public byte Class {
- get {
- throw new NotImplementedException ();
- }
+ internal SqlErrorCollection() {
}
- [MonoTODO]
- public int LineNumber {
- get {
- throw new NotImplementedException ();
- }
- }
-
- [MonoTODO]
- public string Message {
- get {
- throw new NotImplementedException ();
- }
- }
-
- [MonoTODO]
- public int Number {
- get {
- throw new NotImplementedException ();
- }
- }
-
- [MonoTODO]
- public string Procedure {
- get {
- throw new NotImplementedException ();
- }
- }
-
- [MonoTODO]
- public string Server {
- get {
- throw new NotImplementedException ();
- }
- }
-
- [MonoTODO]
- public string Source {
- get {
- throw new NotImplementedException ();
- }
- }
-
- [MonoTODO]
- public byte State {
- get {
- throw new NotImplementedException ();
- }
+ internal SqlErrorCollection(byte theClass, int lineNumber,
+ string message, int number, string procedure,
+ string server, string source, byte state) {
+
+ Add (theClass, lineNumber, message,
+ number, procedure,
+ server, source, state);
}
+ #region Properties
+
[MonoTODO]
public int Count {
get {
- throw new NotImplementedException ();
+ return errorList.Count;
}
}
throw new NotImplementedException ();
}
+ [MonoTODO]
+ // Index property (indexer)
+ public SqlError this[int index] {
+ get {
+ return (SqlError) errorList[index];
+ }
+ }
+
#endregion
#region Methods
}
#endregion
+ internal void Add(SqlError error) {
+ errorList.Add(error);
+ }
+
+ internal void Add(byte theClass, int lineNumber,
+ string message, int number, string procedure,
+ string server, string source, byte state) {
+
+ SqlError error = new SqlError(theClass,
+ lineNumber, message,
+ number, procedure,
+ server, source, state);
+ Add(error);
+ }
+
#region Destructors
- // FIXME: do the destructor
-/*
[MonoTODO]
- [ClassInterface(ClassInterfaceType.AutoDual)]
- ~SqlError()
+ ~SqlErrorCollection()
{
-
+ // FIXME: do the destructor - release resources
}
-*/
- #endregion
-
+ #endregion
}
}
//
using System;
using System.Data;
+using System.Runtime.Serialization;
namespace System.Data.SqlClient
{
/// </summary>
public sealed class SqlException : SystemException
{
+ private SqlErrorCollection errors = new SqlErrorCollection();
+
+ internal SqlException() {
+
+ }
+
+ internal SqlException(byte theClass, int lineNumber,
+ string message, int number, string procedure,
+ string server, string source, byte state) {
+
+ errors = new SqlErrorCollection (theClass,
+ lineNumber, message,
+ number, procedure,
+ server, source, state);
+ }
+
#region Properties
-
+
[MonoTODO]
public byte Class {
get {
- throw new NotImplementedException ();
+ if(errors.Count == 0)
+ return 0; // FIXME: throw exception here?
+ else
+ return errors[0].Class;
}
+
set {
- throw new NotImplementedException ();
+ errors[0].SetClass(value);
}
}
[MonoTODO]
public SqlErrorCollection Errors {
get {
- throw new NotImplementedException ();
+ return errors;
}
+
set {
- throw new NotImplementedException ();
+ errors = value;
}
}
[MonoTODO]
public int LineNumber {
get {
- throw new NotImplementedException ();
+ if(errors.Count == 0)
+ return 0; // FIXME: throw exception here?
+ return errors[0].LineNumber;
}
set {
- throw new NotImplementedException ();
+ errors[0].SetLineNumber(value);
}
}
[MonoTODO]
public override string Message {
get {
- throw new NotImplementedException ();
+ if(errors.Count == 0)
+ return ""; // FIXME: throw exception?
+ else {
+ String msg = "";
+ int i = 0;
+
+ for(i = 0; i < errors.Count - 1; i++) {
+ msg = msg + errors[i].Message + "\n";
+ }
+ msg = msg + errors[i];
+
+ return msg;
+ }
}
}
[MonoTODO]
public int Number {
get {
- throw new NotImplementedException ();
+ if(errors.Count == 0)
+ return 0; // FIXME: throw exception?
+ else
+ return errors[0].Number;
}
set {
- throw new NotImplementedException ();
+ errors[0].SetNumber(value);
}
}
[MonoTODO]
public string Procedure {
get {
- throw new NotImplementedException ();
+ if(errors.Count == 0)
+ return ""; // FIXME: throw exception?
+ else
+ return errors[0].Procedure;
}
set {
- throw new NotImplementedException ();
+ errors[0].SetProcedure(value);
}
}
[MonoTODO]
public string Server {
get {
- throw new NotImplementedException ();
+ if(errors.Count == 0)
+ return ""; // FIXME: throw exception?
+ else
+ return errors[0].Server;
}
set {
- throw new NotImplementedException ();
+ errors[0].SetServer(value);
}
}
[MonoTODO]
public override string Source {
get {
- throw new NotImplementedException ();
+ if(errors.Count == 0)
+ return ""; // FIXME: throw exception?
+ else
+ return errors[0].Source;
}
set {
- throw new NotImplementedException ();
+ errors[0].SetSource(value);
}
}
[MonoTODO]
public byte State {
get {
- throw new NotImplementedException ();
+ if(errors.Count == 0)
+ return 0; // FIXME: throw exception?
+ else
+ return errors[0].State;
}
set {
- throw new NotImplementedException ();
+ errors[0].SetState(value);
}
}
#endregion // Properties
+
+ #region Methods
+
+ [MonoTODO]
+ public override void GetObjectData(SerializationInfo si,
+ StreamingContext context) {
+ // FIXME: to do
+ }
+
+ // [Serializable]
+ // [ClassInterface(ClassInterfaceType.AutoDual)]
+ public override string ToString() {
+ String toStr = "";
+ for (int i = 0; i < errors.Count; i++) {
+ toStr = toStr + errors[i].ToString() + "\n";
+ }
+ return toStr;
+ }
+
+ internal void Add(byte theClass, int lineNumber,
+ string message, int number, string procedure,
+ string server, string source, byte state) {
+
+ errors.Add (theClass, lineNumber, message,
+ number, procedure,
+ server, source, state);
+ }
+
+ [MonoTODO]
+ ~SqlException() {
+ // FIXME: destructor to release resources
+ }
+
+ #endregion // Methods
}
}
{
public sealed class SqlInfoMessageEventArgs : EventArgs
{
+ [MonoTODO]
public SqlErrorCollection Errors {
get {
throw new NotImplementedException ();
}
}
+ [MonoTODO]
public string Message
{
get {
}
}
+ [MonoTODO]
public string Source {
get {
throw new NotImplementedException ();
}
}
+ [MonoTODO]
public override string ToString() {
// representation of InfoMessage event
}
+
+ [MonoTODO]
+ ~SqlInfoMessageEventArgs() {
+ // FIXME: destructor needs to release resources
+ }
}
}
--- /dev/null
+//
+// System.Data.SqlClient.SqlInfoMessageEventHandler.cs
+//
+// Author:
+// Rodrigo Moya (rodrigo@ximian.com)
+// Daniel Morgan (danmorg@sc.rr.com)
+//
+// (C) Ximian, Inc 2002
+//
+
+using System;
+using System.Data;
+
+namespace System.Data.SqlClient
+{
+ public delegate void
+ SqlInfoMessageEventHandler (object sender,
+ SqlInfoMessageEventArgs e);
+}
// (C) Ximian, Inc. 2002
//
using System;
+using System.ComponentModel;
using System.Data;
using System.Data.Common;
using System.Runtime.InteropServices;
// IDbDataParameter, IDataParameter, ICloneable
public sealed class SqlParameter : IDbDataParameter, IDataParameter
{
+ [MonoTODO]
+ public SqlParameter () {
+ // FIXME: do this
+ }
+
+ [MonoTODO]
+ public SqlParameter (string parameterName, object value) {
+ // FIXME: do this
+ }
+
+ [MonoTODO]
+ public SqlParameter(string parameterName, SqlDbType dbType) {
+ // FIXME: do this
+ }
+
+ [MonoTODO]
+ public SqlParameter(string parameterName, SqlDbType dbType,
+ int size) {
+ // FIXME: do this
+ }
+
+ [MonoTODO]
+ public SqlParameter(string parameterName, SqlDbType dbType,
+ int size, string sourceColumn) {
+ // FIXME: do this
+ }
+
+ [MonoTODO]
+ public SqlParameter(string parameterName, SqlDbType dbType,
+ int size, ParameterDirection direction,
+ bool isNullable, byte precision,
+ byte scale, string sourceColumn,
+ DataRowVersion sourceVersion, object value) {
+ // FIXME: do this
+ }
+
+
[MonoTODO]
public DbType DbType {
get {
}
}
+ [MonoTODO]
+ public int Offset {
+ get {
+ throw new NotImplementedException ();
+ }
+
+ set {
+ throw new NotImplementedException ();
+ }
+ }
+
[MonoTODO]
public string ParameterName {
get {
throw new NotImplementedException ();
}
}
+
+ [MonoTODO]
+ public SqlDbType SqlDbType {
+ get {
+ throw new NotImplementedException ();
+ }
+
+ set {
+ throw new NotImplementedException ();
+ }
+ }
[MonoTODO]
public object Value {
}
}
+ [MonoTODO]
+ public override string ToString() {
+ throw new NotImplementedException ();
+ }
}
}
//
using System;
+using System.ComponentModel;
using System.Data;
using System.Collections;
--- /dev/null
+//
+// System.Data.SqlClient.SqlRowUpdatedEventArgs.cs
+//
+// Author:
+// Rodrigo Moya (rodrigo@ximian.com)
+// Daniel Morgan (danmorg@sc.rr.com)
+//
+// (C) Ximian, Inc 2002
+//
+
+using System;
+using System.Data;
+using System.Data.Common;
+
+namespace System.Data.SqlClient {
+ public sealed class SqlRowUpdatedEventArgs : RowUpdatedEventArgs {
+
+ [MonoTODO]
+ public SqlRowUpdatedEventArgs (DataRow row,
+ IDbCommand command, StatementType statementType,
+ DataTableMapping tableMapping) {
+ // FIXME: do the constructor
+ }
+
+ [MonoTODO]
+ public new SqlCommand Command {
+ get {
+
+ }
+ }
+
+ [MonoTODO]
+ ~SqlRowUpdatedEventArgs () {
+ // FIXME: need destructor to release resources
+ }
+
+ }
+}
--- /dev/null
+//
+// System.Data.SqlClient.SqlRowUpdatedEventHandler.cs
+//
+// Author:
+// Rodrigo Moya (rodrigo@ximian.com)
+// Daniel Morgan (danmorg@sc.rr.com)
+//
+// (C) Ximian, Inc 2002
+//
+
+using System;
+using System.Data;
+
+namespace System.Data.SqlClient
+{
+ public delegate void SqlRowUpdatedEventHandler(object sender,
+ SqlRowUpdatedEventArgs e);
+}
--- /dev/null
+//
+// System.Data.SqlClient.SqlRowUpdatingEventArgs.cs
+//
+// Author:
+// Rodrigo Moya (rodrigo@ximian.com)
+// Daniel Morgan (danmorg@sc.rr.com)
+//
+// (C) Ximian, Inc 2002
+//
+
+using System;
+using System.Data;
+using System.Data.Common;
+
+namespace System.Data.SqlClient
+{
+ public sealed class SqlRowUpdatingEventArgs : RowUpdatingEventArgs
+ {
+ [MonoTODO]
+ public SqlRowUpdatingEventArgs( DataRow row,
+ IDbCommand command, StatementType statementType,
+ DataTableMapping tableMapping) {
+ // FIXME: do the constructor
+ }
+
+ [MonoTODO]
+ public new SqlCommand Command {
+ get {
+ throw new NotImplementedException ();
+ }
+
+ set {
+ throw new NotImplementedException ();
+ }
+ }
+
+ [MonoTODO]
+ ~SqlRowUpdatingEventArgs() {
+ // FIXME: create destructor to release resources
+ }
+ }
+}
--- /dev/null
+//
+// System.Data.SqlClient.SqlRowUpdatingEventHandler.cs
+//
+// Author:
+// Rodrigo Moya (rodrigo@ximian.com)
+// Daniel Morgan (danmorg@sc.rr.com)
+//
+// (C) Ximian, Inc 2002
+//
+
+using System;
+using System.Data;
+
+namespace System.Data.SqlClient
+{
+ public delegate void SqlRowUpdatingEventHandler(object sender,
+ SqlRowUpdatingEventArgs e);
+}
//
// Author:
// Rodrigo Moya (rodrigo@ximian.com)
+// Daniel Morgan (danmorg@sc.rr.com)
//
// (C) Ximian, Inc. 2002
//
+
+// use #define DEBUG_SqlTransaction if you want to spew debug messages
+// #define DEBUG_SqlTransaction
+
+
using System;
using System.Data;
using System.Data.Common;
{
#region Fields
+ private bool doingTransaction = false;
private SqlConnection conn = null;
- // How do you get/set the
- // IsolationLevel in PostgreSQL?
private IsolationLevel isolationLevel =
IsolationLevel.ReadCommitted;
- // There are two IsolationLevel's for PostgreSQL:
+ // There are only two IsolationLevel's for PostgreSQL:
// ReadCommitted and Serializable,
// but ReadCommitted is the default
[MonoTODO]
public void Commit ()
{
- IntPtr pgResult;
- ExecStatusType execStatus;
-
- pgResult = PostgresLibrary.
- PQexec (conn.PostgresConnection,
- "COMMIT");
- /* FIXME: check result and emit
- * exceptions on errors
- */
- execStatus = PostgresLibrary.
- PQresultStatus (pgResult);
-
- String cmdStatus;
- cmdStatus = PostgresLibrary.
- PQcmdStatus(pgResult);
-
- Console.WriteLine("*** Command Status: " +
- cmdStatus);
-
- PostgresLibrary.PQclear (pgResult);
+ if(doingTransaction == false)
+ throw new InvalidOperationException(
+ "Begin transaction was not " +
+ "done earlier " +
+ "thus PostgreSQL can not " +
+ "Commit transaction.");
+
+ SqlCommand cmd = new SqlCommand("COMMIT", conn);
+ cmd.ExecuteNonQuery();
+
+ doingTransaction = false;
}
[MonoTODO]
public void Rollback()
{
- IntPtr pgResult;
- ExecStatusType execStatus;
-
- pgResult = PostgresLibrary.
- PQexec (conn.PostgresConnection,
- "ROLLBACK");
- /* FIXME: check result and emit
- * exceptions on errors
- */
- execStatus = PostgresLibrary.
- PQresultStatus (pgResult);
-
- String cmdStatus;
- cmdStatus = PostgresLibrary.
- PQcmdStatus(pgResult);
-
- Console.WriteLine("*** Command Status: " +
- cmdStatus);
-
- PostgresLibrary.PQclear (pgResult);
+ if(doingTransaction == false)
+ throw new InvalidOperationException(
+ "Begin transaction was not " +
+ "done earlier " +
+ "thus PostgreSQL can not " +
+ "Rollback transaction.");
+
+ SqlCommand cmd = new SqlCommand("ROLLBACK", conn);
+ cmd.ExecuteNonQuery();
+
+ doingTransaction = false;
+ }
+
+ // For PostgreSQL, Rollback(string) will not be implemented
+ // because PostgreSQL does not support Savepoints
+ [Obsolete]
+ public void Rollback(string transactionName) {
+ // throw new NotImplementedException ();
+ Rollback();
+ }
+
+ // For PostgreSQL, Save(string) will not be implemented
+ // because PostgreSQL does not support Savepoints
+ [Obsolete]
+ public void Save (string savePointName) {
+ // throw new NotImplementedException ();
}
#endregion // Public Methods
internal void Begin()
{
- IntPtr pgResult;
- ExecStatusType execStatus;
-
- pgResult = PostgresLibrary.
- PQexec (conn.PostgresConnection,
- "BEGIN");
- /* FIXME: check result and emit
- * exceptions on errors
- */
- execStatus = PostgresLibrary.
- PQresultStatus (pgResult);
-
- String cmdStatus;
- cmdStatus = PostgresLibrary.
- PQcmdStatus(pgResult);
-
- Console.WriteLine("*** Command Status: " +
- cmdStatus);
-
- PostgresLibrary.PQclear (pgResult);
+ if(doingTransaction == true)
+ throw new InvalidOperationException(
+ "Transaction has begun " +
+ "and PostgreSQL does not " +
+ "support nested transactions.");
+
+ SqlCommand cmd = new SqlCommand("BEGIN", conn);
+ cmd.ExecuteNonQuery();
+
+ doingTransaction = true;
}
internal void SetIsolationLevel(IsolationLevel isoLevel)
{
+ String sSql = "SET TRANSACTION ISOLATION LEVEL ";
+
+ switch (isoLevel) \r
+ {
+ case IsolationLevel.ReadCommitted:
+ sSql += "READ COMMITTED";
+ break;
+
+ case IsolationLevel.Serializable:
+ sSql += "SERIALIZABLE";
+ break;
+ default:
+ // FIXME: generate exception here
+ // PostgreSQL only supports:
+ // ReadCommitted or Serializable
+ break;
+ }
+ SqlCommand cmd = new SqlCommand(sSql, conn);
+ cmd.ExecuteNonQuery();
+
this.isolationLevel = isoLevel;
}
}
}
+ internal bool DoingTransaction {
+ get {
+ return doingTransaction;
+ }
+ }
+
+ #endregion Properties
+
+ #region Destructors
+
+ // Destructors aka Finalize and Dispose
+
[MonoTODO]
public void Dispose()
{
// FIXME: need to properly release resources
+ // Dispose(true);
}
-
- #endregion // Properties
+
+ // Destructor
+ [MonoTODO]
+ // [Serializable]\r
+ // [ClassInterface(ClassInterfaceType.AutoDual)]
+ ~SqlTransaction() {
+ // FIXME: need to properly release resources
+ // Dispose(false);
+ }
+
+ #endregion // Destructors
}
}
<excludes name="System.Data.SqlClient/SqlDataAdapter.cs"/>\r
<excludes name="System.Data.SqlClient/SqlDataReader.cs"/>\r
<excludes name="System.Data.SqlClient/SqlInfoMessageEventArgs.cs"/>\r
+ <excludes name="System.Data.SqlClient/SqlRowUpdatingEventArgs.cs"/>\r
+ <excludes name="System.Data.SqlClient/SqlRowUpdatedEventArgs.cs"/>\r
+ <excludes name="System.Data.SqlClient/SqlInfoMessageEventHandler.cs"/>\r
+ <excludes name="System.Data.SqlClient/SqlRowUpdatingEventHandler.cs"/>\r
+ <excludes name="System.Data.SqlClient/SqlRowUpdatedEventHandler.cs"/>\r
+ <excludes name="System.Data.SqlClient/SqlClientPermission.cs"/>\r
+ <excludes name="System.Data.SqlClient/SqlClientPermissionAttribute.cs"/>\r
+ <excludes name="System.Data.SqlClient/SqlCommandBuilder.cs"/>\r
<excludes name="System.Data.SqlTypes/*"/>\r
</sources>\r
<references>\r
--- /dev/null
+//
+// TestSqlInsert.cs
+//
+// To Test SqlConnection and SqlCommand by connecting
+// to a PostgreSQL database
+// and then executing an INSERT SQL statement
+//
+// To use:
+// change strings to your database, userid, tables, etc...:
+// connectionString
+// insertStatement
+//
+// To test:
+// mcs TestSqlInsert.cs -r System.Data
+// mint TestSqlInsert.exe
+//
+// Author:
+// Rodrigo Moya (rodrigo@ximian.com)
+// Daniel Morgan (danmorg@sc.rr.com)
+//
+// (C) Ximian, Inc 2002
+//
+
+using System;
+using System.Data;
+using System.Data.SqlClient;
+
+namespace TestSystemDataSqlClient
+{
+ class TestSqlInsert
+ {
+ [STAThread]
+ static void Main(string[] args) {
+ SqlConnection conn;
+ SqlCommand cmd;
+ SqlTransaction trans;
+
+ int rowsAffected;
+
+ String connectionString;
+ String insertStatement;
+ String deleteStatement;
+
+ connectionString =
+ "host=localhost;" +
+ "dbname=test;" +
+ "user=danmorg;" +
+ "password=viewsonic";
+
+ insertStatement =
+ "insert into sometable " +
+ "(tid, tdesc) " +
+ "values ('beer', 'Beer for All!') ";
+
+ deleteStatement =
+ "delete from NoSuchTable " +
+ "where tid = 'beer' ";
+
+ try {
+ // Connect to a PostgreSQL database
+ Console.WriteLine ("Connect to database...");
+ conn = new SqlConnection(connectionString);
+ conn.Open();
+
+ // begin transaction
+ Console.WriteLine ("Begin Transaction...");
+ trans = conn.BeginTransaction();
+
+ // create SQL DELETE command
+ Console.WriteLine ("Create Command initializing " +
+ "with an DELETE statement...");
+ cmd = new SqlCommand (deleteStatement, conn);
+
+ // execute the DELETE SQL command
+ Console.WriteLine ("Execute DELETE SQL Command...");
+ cmd.ExecuteNonQuery();
+ rowsAffected = cmd.ExecuteNonQuery();
+ Console.WriteLine ("Rows Affected: " + rowsAffected);
+
+ // change the SQL command to an SQL INSERT Command
+ Console.WriteLine ("Now use INSERT SQL Command...");
+ cmd.CommandText = insertStatement;
+
+ // execute the INSERT SQL command
+ Console.WriteLine ("Execute INSERT SQL Command...");
+ rowsAffected = cmd.ExecuteNonQuery();
+ Console.WriteLine ("Rows Affected: " + rowsAffected);
+
+ // if successfull at INSERT, commit the transaction,
+ // otherwise, do a rollback the transaction using
+ // trans.Rollback();
+ Console.WriteLine ("Commit transaction...");
+ trans.Commit();
+
+ // Close connection to database
+ Console.WriteLine ("Close database connection...");
+ conn.Close();
+
+ Console.WriteLine ("Assuming everything " +
+ "was successful.");
+ Console.WriteLine ("Verify data in database to " +
+ "see if row is there.");
+ }
+ catch(SqlException e) {
+ // Display the SQL Errors and Rollback the database
+ Console.WriteLine("SqlException caught: " +
+ e.ToString());
+ trans.Rollback();
+ Console.WriteLine("Database has been Rolled back!");
+ }
+ finally {
+ if(conn.State == ConnectionState.Open)
+ conn.Close();
+ }
+ }
+ }
+}
//
-// System.Data.SqlClient.SqlError.cs
+// TestSqlInsert.cs
//
// To Test SqlConnection and SqlCommand by connecting
// to a PostgreSQL database
// connectionString
// insertStatement
//
+// To test:
+// mcs TestSqlInsert.cs -r System.Data
+// mint TestSqlInsert.exe
+//
// Author:
// Rodrigo Moya (rodrigo@ximian.com)
// Daniel Morgan (danmorg@sc.rr.com)
SqlCommand cmd;
SqlTransaction trans;
+ int rowsAffected;
+
String connectionString;
String insertStatement;
String deleteStatement;
// Connect to a PostgreSQL database
Console.WriteLine ("Connect to database...");
conn = new SqlConnection(connectionString);
+ conn.Open();
// begin transaction
Console.WriteLine ("Begin Transaction...");
// execute the DELETE SQL command
Console.WriteLine ("Execute DELETE SQL Command...");
cmd.ExecuteNonQuery();
+ rowsAffected = cmd.ExecuteNonQuery();
+ Console.WriteLine ("Rows Affected: " + rowsAffected);
// change the SQL command to an SQL INSERT Command
Console.WriteLine ("Now use INSERT SQL Command...");
// execute the INSERT SQL command
Console.WriteLine ("Execute INSERT SQL Command...");
cmd.ExecuteNonQuery();
+ rowsAffected = cmd.ExecuteNonQuery();
+ Console.WriteLine ("Rows Affected: " + rowsAffected);
// if successfull at INSERT, commit the transaction,
// otherwise, do a rollback the transaction using
--- /dev/null
+//
+// TestSqlIsolationLevel.
+//
+// To Test Setting Isolation Level of SqlTransaction
+// to a PostgreSQL database
+//
+// To use:
+// change strings to your database, userid, tables, etc...:
+// connectionString
+// insertStatement
+//
+// To test:
+// mcs TestSqlIsolationLevel.cs -r System.Data
+// mint TestSqlIsolationLevel.exe
+//
+// Author:
+// Rodrigo Moya (rodrigo@ximian.com)
+// Daniel Morgan (danmorg@sc.rr.com)
+//
+// (C) Ximian, Inc 2002
+//
+
+using System;
+using System.Data;
+using System.Data.SqlClient;
+
+namespace TestSystemDataSqlClient
+{
+ class TestSqlInsert
+ {
+ [STAThread]
+ static void Main(string[] args)
+ {
+ SqlConnection conn;
+ SqlCommand cmd;
+ SqlTransaction trans;
+
+ int rowsAffected;
+
+ String connectionString;
+ String insertStatement;
+ String deleteStatement;
+
+ connectionString =
+ "host=localhost;" +
+ "dbname=test;" +
+ "user=danmorg;" +
+ "password=viewsonic";
+
+ insertStatement =
+ "insert into sometable " +
+ "(tid, tdesc) " +
+ "values ('beer', 'Beer for All!') ";
+
+ deleteStatement =
+ "delete from sometable " +
+ "where tid = 'beer' ";
+
+ // Connect to a PostgreSQL database
+ Console.WriteLine ("Connect to database...");
+ conn = new SqlConnection(connectionString);
+ conn.Open();
+
+ // begin transaction
+ Console.WriteLine ("Begin Transaction...");
+ trans = conn.BeginTransaction(IsolationLevel.Serializable);
+
+ // create SQL DELETE command
+ Console.WriteLine ("Create Command initializing " +
+ "with an DELETE statement...");
+ cmd = new SqlCommand (deleteStatement, conn);
+
+ // execute the DELETE SQL command
+ Console.WriteLine ("Execute DELETE SQL Command...");
+ cmd.ExecuteNonQuery();
+
+ // change the SQL command to an SQL INSERT Command
+ Console.WriteLine ("Now use INSERT SQL Command...");
+ cmd.CommandText = insertStatement;
+
+ // execute the INSERT SQL command
+ Console.WriteLine ("Execute INSERT SQL Command...");
+ rowsAffected = cmd.ExecuteNonQuery();
+ Console.WriteLine ("Rows Affected: " + rowsAffected);
+
+ // if successfull at INSERT, commit the transaction,
+ // otherwise, do a rollback the transaction using
+ // trans.Rollback();
+ // FIXME: need to have exceptions working in
+ // SqlClient classes before you can do rollback
+ Console.WriteLine ("Commit transaction...");
+ trans.Commit();
+
+ // Close connection to database
+ Console.WriteLine ("Close database connection...");
+ conn.Close();
+
+ Console.WriteLine ("Assuming everything " +
+ "was successful.");
+ Console.WriteLine ("Verify data in database to " +
+ "see if row is there.");
+ }
+ }
+}