C
CEO Gargantua
I set up a class for managing SqlConnection's.
Then I added a method to open and return a SqlConnection (see below).
Question, if I instantiate this class in another class:
sql400con connection = new sql400con();
and use the method
So:
SqlConnection newConn = connection.makeSQLConnection();
Question:
What is the best way to dispose of this SqlConnection?
In a destructor?
From the calling class?
How do I reference a member of a member method from the class itself (
to implement in the destructor ) ?
using System;
using System.Data.SqlClient;
using IBM.Data.DB2.iSeries;
using System.Configuration;
namespace Trigger
{
/// <summary>
/// Summary description for sql400conn.
/// </summary>
public class sql400conn
{
public sql400conn()
{
//
// TODO: Add constructor logic here
//
}
public iDB2Connection makeDB2Connection()
{
iDB2Connection c_iDB2Connection = new iDB2Connection();
return c_iDB2Connection;
}
public SqlConnection makeSQLConnection()
{
SqlConnection c_SqlConnection = new SqlConnection(
c_SqlConnection.Open():
);
return c_SqlConnection;
}
}
}
--
incognito...updated almost daily
http://kentpsychedelic.blogspot.com
Texeme Textcasting Technology
http://texeme.com
Then I added a method to open and return a SqlConnection (see below).
Question, if I instantiate this class in another class:
sql400con connection = new sql400con();
and use the method
So:
SqlConnection newConn = connection.makeSQLConnection();
Question:
What is the best way to dispose of this SqlConnection?
In a destructor?
From the calling class?
How do I reference a member of a member method from the class itself (
to implement in the destructor ) ?
using System;
using System.Data.SqlClient;
using IBM.Data.DB2.iSeries;
using System.Configuration;
namespace Trigger
{
/// <summary>
/// Summary description for sql400conn.
/// </summary>
public class sql400conn
{
public sql400conn()
{
//
// TODO: Add constructor logic here
//
}
public iDB2Connection makeDB2Connection()
{
iDB2Connection c_iDB2Connection = new iDB2Connection();
return c_iDB2Connection;
}
public SqlConnection makeSQLConnection()
{
SqlConnection c_SqlConnection = new SqlConnection(
c_SqlConnection.Open():
);
return c_SqlConnection;
}
}
}
--
incognito...updated almost daily
http://kentpsychedelic.blogspot.com
Texeme Textcasting Technology
http://texeme.com