Connect to the database with more than one single layer.
-
Description Image http://baymyo.com/gallery/pimage/multi_sql_code_generate_gif-50cf8.gif[^] Open Source Code, Downlaod Click Here! MSSQL, ORACLE, MySQL, and OleDb to establish connections to servers via a single layer. The following block of code to show the connection layer.
public class MConnection : IDisposable
{
#region IDisposable Members
public void Dispose()
{
this.Close();
if (this.m_ClientConnection != null)
this.m_ClientConnection.Dispose();
GC.SuppressFinalize(this);
}
#endregion#region --- Member --- IMConnection m\_ClientConnection; internal IMConnection ClientConnection { get { return m\_ClientConnection; } } private MClientProvider m\_ClientProvider; public MClientProvider ClientProvider { get { return m\_ClientProvider; } } private string m\_ConnectionString; public string ConnectionString { get { return m\_ConnectionString; } } private System.Data.ConnectionState m\_State; public System.Data.ConnectionState State { get { return m\_State; } } public System.ComponentModel.ISite Site { get { return m\_ClientConnection.Site; } set { m\_ClientConnection.Site = value; } } public string ServerVersion { get { return m\_ClientConnection.ServerVersion; } } public string Database { get { return m\_ClientConnection.Database; } } public string DataSource { get { return m\_ClientConnection.DataSource; } } #endregion #region --- Constructor --- public MConnection(MClientProvider clientProvider) { this.m\_ClientProvider = clientProvider; switch (this.m\_Cli
-
Description Image http://baymyo.com/gallery/pimage/multi_sql_code_generate_gif-50cf8.gif[^] Open Source Code, Downlaod Click Here! MSSQL, ORACLE, MySQL, and OleDb to establish connections to servers via a single layer. The following block of code to show the connection layer.
public class MConnection : IDisposable
{
#region IDisposable Members
public void Dispose()
{
this.Close();
if (this.m_ClientConnection != null)
this.m_ClientConnection.Dispose();
GC.SuppressFinalize(this);
}
#endregion#region --- Member --- IMConnection m\_ClientConnection; internal IMConnection ClientConnection { get { return m\_ClientConnection; } } private MClientProvider m\_ClientProvider; public MClientProvider ClientProvider { get { return m\_ClientProvider; } } private string m\_ConnectionString; public string ConnectionString { get { return m\_ConnectionString; } } private System.Data.ConnectionState m\_State; public System.Data.ConnectionState State { get { return m\_State; } } public System.ComponentModel.ISite Site { get { return m\_ClientConnection.Site; } set { m\_ClientConnection.Site = value; } } public string ServerVersion { get { return m\_ClientConnection.ServerVersion; } } public string Database { get { return m\_ClientConnection.Database; } } public string DataSource { get { return m\_ClientConnection.DataSource; } } #endregion #region --- Constructor --- public MConnection(MClientProvider clientProvider) { this.m\_ClientProvider = clientProvider; switch (this.m\_Cli
What is this? is there a question hidden somewhere? this is a discussion forum. If you want to share something, write an article, don't just dump a bunch of undocumented code. :doh:
Luc Pattyn [My Articles] Nil Volentibus Arduum
-
What is this? is there a question hidden somewhere? this is a discussion forum. If you want to share something, write an article, don't just dump a bunch of undocumented code. :doh:
Luc Pattyn [My Articles] Nil Volentibus Arduum
I think he/she is developing a taste for Spam.
Unrequited desire is character building. OriginalGriff I'm sitting here giving you a standing ovation - Len Goodman
-
I think he/she is developing a taste for Spam.
Unrequited desire is character building. OriginalGriff I'm sitting here giving you a standing ovation - Len Goodman
I realize we can't get Bacon all the time. :-D
Luc Pattyn [My Articles] Nil Volentibus Arduum
-
Description Image http://baymyo.com/gallery/pimage/multi_sql_code_generate_gif-50cf8.gif[^] Open Source Code, Downlaod Click Here! MSSQL, ORACLE, MySQL, and OleDb to establish connections to servers via a single layer. The following block of code to show the connection layer.
public class MConnection : IDisposable
{
#region IDisposable Members
public void Dispose()
{
this.Close();
if (this.m_ClientConnection != null)
this.m_ClientConnection.Dispose();
GC.SuppressFinalize(this);
}
#endregion#region --- Member --- IMConnection m\_ClientConnection; internal IMConnection ClientConnection { get { return m\_ClientConnection; } } private MClientProvider m\_ClientProvider; public MClientProvider ClientProvider { get { return m\_ClientProvider; } } private string m\_ConnectionString; public string ConnectionString { get { return m\_ConnectionString; } } private System.Data.ConnectionState m\_State; public System.Data.ConnectionState State { get { return m\_State; } } public System.ComponentModel.ISite Site { get { return m\_ClientConnection.Site; } set { m\_ClientConnection.Site = value; } } public string ServerVersion { get { return m\_ClientConnection.ServerVersion; } } public string Database { get { return m\_ClientConnection.Database; } } public string DataSource { get { return m\_ClientConnection.DataSource; } } #endregion #region --- Constructor --- public MConnection(MClientProvider clientProvider) { this.m\_ClientProvider = clientProvider; switch (this.m\_Cli
internal MCommand(object command, MConnection connection)
{
try
{
this.m_Connection = connection;
switch (connection.ClientProvider)
{
case MClientProvider.MSSQL:
this.m_ClientCommand = new MSSQLCommand(command as System.Data.SqlClient.SqlCommand);
break;
case MClientProvider.ORACLE:
this.m_ClientCommand = new ORACLECommand(command as System.Data.OracleClient.OracleCommand);
break;
case MClientProvider.MySQL:
break;
case MClientProvider.OleDb:
this.m_ClientCommand = new OLEDBCommand(command as System.Data.OleDb.OleDbCommand);
break;
}
this.m_ClientCommand.Connection = connection;
this.m_CommandText = this.m_ClientCommand.CommandText;
this.m_CommandType = this.m_ClientCommand.CommandType;
this.m_CommandTimeout = this.m_ClientCommand.CommandTimeout;
}
catch (Exception ex)
{
throw ex;
}Loose the switch, and have the connection create[^] a command;
command = connection.CreateCommand();
It'd also be wise to remove the redunant error-handler. Catching an exception merely to rethrow it doesn't make much sense. If you really feel like it, then make it
catch (Exception ex)
{
throw;
}Bastard Programmer from Hell :suss:
-
Description Image http://baymyo.com/gallery/pimage/multi_sql_code_generate_gif-50cf8.gif[^] Open Source Code, Downlaod Click Here! MSSQL, ORACLE, MySQL, and OleDb to establish connections to servers via a single layer. The following block of code to show the connection layer.
public class MConnection : IDisposable
{
#region IDisposable Members
public void Dispose()
{
this.Close();
if (this.m_ClientConnection != null)
this.m_ClientConnection.Dispose();
GC.SuppressFinalize(this);
}
#endregion#region --- Member --- IMConnection m\_ClientConnection; internal IMConnection ClientConnection { get { return m\_ClientConnection; } } private MClientProvider m\_ClientProvider; public MClientProvider ClientProvider { get { return m\_ClientProvider; } } private string m\_ConnectionString; public string ConnectionString { get { return m\_ConnectionString; } } private System.Data.ConnectionState m\_State; public System.Data.ConnectionState State { get { return m\_State; } } public System.ComponentModel.ISite Site { get { return m\_ClientConnection.Site; } set { m\_ClientConnection.Site = value; } } public string ServerVersion { get { return m\_ClientConnection.ServerVersion; } } public string Database { get { return m\_ClientConnection.Database; } } public string DataSource { get { return m\_ClientConnection.DataSource; } } #endregion #region --- Constructor --- public MConnection(MClientProvider clientProvider) { this.m\_ClientProvider = clientProvider; switch (this.m\_Cli
Seriously, why do you reinvent the wheel, badly. It's already been done, by Microsoft. So read up on DBProviderFactories[^] instead. A little on how to use them here[^].
Light moves faster than sound. That is why some people appear bright, until you hear them speak. List of common misconceptions