Re: VS2005 and SQL Express: Internal .Net Framework Data Provider
- From: "Cowboy \(Gregory A. Beamer\)" <NoSpamMgbworld@xxxxxxxxxxxxxxxxxx>
- Date: Mon, 11 Sep 2006 07:59:12 -0500
I am familiar with that one, as I did the same awhile back. I was trying to
remember the specifics. I am glad you found your answer.
--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
*************************************************
Think outside of the box!
*************************************************
"den 2005" <den2005@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:5940DBE8-71A7-4303-8075-B653075C43D2@xxxxxxxxxxxxxxxx
Thanks Gregory for the reply..
The error occurs when the connection is being close, I think triggered in
the destructor...It works in 1.1 and Sql 2000 as my co-workers using this
class. Wel, I created a new class without the destructor..
dennis
--
MCP Year 2005, Philippines
"Cowboy (Gregory A. Beamer)" wrote:
What is the error precisely? THe interal connection is underneath the
connection object you use. This allows for connection pooling, etc. The
closing of the connection prior to creating a new one is one shot, but I
do
not see what is calling this.
Run through debug until it dies and focus on the exact location. Then,
back
up a few lines, put a breakpoint and walk through. You will eventually
find
the precise error location. If my thinking is correct, you are ending up
with the inability to re-instantiate the object as it is in the midst of
destruction, but this is just a guess.
--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
*************************************************
Think outside of the box!
*************************************************
"den 2005" <den2005@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:3BC55BD8-5D29-41FD-B75A-0CC7380C7A6A@xxxxxxxxxxxxxxxx
Hi everybody,
Is there anybody can tell me what this error meant? Where is source of
error? There is a class library DLL created by another person. I used
C#
(VS
2005 Professional Edition) and SQL Server 2005 Express Edition and also
used
Visual SourceSafe 6.0.
In this class,
There is a constructor and destructor in the destructor it calls the
CloseConnection() method where the error occurs.
[code]
I am using this methods
public void CreateConnection(string ConnectionString) {
// Check first if the connection is open, if yes, close it
first
before creating a new one
CloseConnection();
// Create the SQLConnection object for the class to use
m_Connection = new SqlConnection(ConnectionString);
}
public void CreateCommand(string StoredProcName) {
// Check first if the command is existing, if yes, set it
first
to null before creating a new one
CloseCommand();
// Check if there is an SQLConnection object existing for
the
command to use
if (m_Connection == null)
CreateConnection();
// Create the SQLCommand object for the class to use
m_Command = new SqlCommand();
m_Command.Connection = m_Connection;
m_Command.CommandType = CommandType.StoredProcedure;
m_Command.CommandText = StoredProcName;
}
public void AddParameter(string ParamName, object ParamValue) {
// Check if there is an SQLCommand existing before adding
the
parameters. If not, then return an exception.
if (m_Command == null)
throw new NullReferenceException("Command Object is
null.
Please execute CreateCommand first before adding parameters.");
// Add the parameter to the SQLCommand object
SqlParameter parameter;
parameter = m_Command.CreateParameter();
parameter.ParameterName = ParamName;
parameter.Value = ParamValue;
m_Command.Parameters.Add(parameter);
parameter = null;
}
public void ExecuteReader() {
// Check if there is an SQLCommand existing before executing
Data Reader. If not, then return an exception.
if (m_Command == null)
throw new NullReferenceException("Command Object is
null.");
// Check if the connection state of the SQLConnection object
is
open, if not open it.
if (m_Connection.State == ConnectionState.Closed)
m_Connection.Open();
// Close first and dispose the existing data reader is there
is
any
CloseDataReader();
// Create the data reader
m_DataReader = m_Command.ExecuteReader();
}
[/code]
[code]
~DataAccessLayer() {
Dispose(true);
}
private void CloseConnection()
{
if (m_Connection != null) {
try {
// Check if connection is already closed, if not,
then
close it
if (m_Connection.State != ConnectionState.Closed)
m_Connection.Close(); <<---Error Occurs here
// Dispose the connection object and set it to null
to
release resources used by the object
m_Connection.Dispose();
m_Connection = null;
}
catch {
throw;
}
}
}
private void CloseCommand() {
if (m_Command != null) {
try {
// Dispose the command object and set it to null to
release resources used by the object
m_Command.Dispose();
m_Command = null;
}
catch {
throw;
}
}
}
private void CloseDataReader() {
if (m_DataReader != null) {
try {
// Check if datareader is already closed, if not,
then
close it
if (!m_DataReader.IsClosed)
m_DataReader.Close();
// Set datareader to null
m_DataReader = null;
}
catch {
throw;
}
}
}
private void CloseDataSet() {
if (m_DataSet != null) {
try {
// Dispose object to release resources used
m_DataSet.Dispose();
m_DataSet = null;
}
catch {
throw;
}
}
}
public void Dispose() {
this.Dispose(true);
GC.SuppressFinalize(this);
}
protected virtual void Dispose(bool disposing) {
// Check to see if Dispose has already been called.
if (!this.m_Disposed) {
if (disposing) {
// Dispose managed resources.
CloseDataReader();
CloseDataSet();
CloseCommand();
CloseConnection();
}
// Release unmanaged resources. If disposing is false,
// only the following code is executed.
}
m_Disposed = true;
}
[/code]
So Base on this codes, what is the problem?
Thanks in Advanced.
den2005
--
MCP Year 2005, Philippines
.
- References:
- VS2005 and SQL Express: Internal .Net Framework Data Provider erro
- From: den 2005
- Re: VS2005 and SQL Express: Internal .Net Framework Data Provider erro
- From: Cowboy \(Gregory A. Beamer\)
- Re: VS2005 and SQL Express: Internal .Net Framework Data Provider
- From: den 2005
- VS2005 and SQL Express: Internal .Net Framework Data Provider erro
- Prev by Date: Re: OOP - Confusion
- Next by Date: Re: How to transfer SQL Express data?
- Previous by thread: Re: VS2005 and SQL Express: Internal .Net Framework Data Provider
- Next by thread: Update a data to a bounded datagrid view
- Index(es):
Relevant Pages
|