473,326 Members | 2,732 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

IDispose problem

Hello

I'm trying to create a class that uses northwind database and use the
IDisposable interface thingy :)

Can someone explain why I get:

Error 1 'Procent.DataJox.Northwind' does not implement interface member
'System.IDisposable.Dispose()' C:\Documents and Settings\Administrator\My
Documents\Visual Studio 2005\Projects\DataJox\DataJox\Class1.cs 10 18
Procent.DataJox

and (on the using(Open()) row):

Warning 2 Possible mistaken empty statement C:\Documents and
Settings\Administrator\My Documents\Visual Studio
2005\Projects\DataJox\DataJox\Class1.cs 16 26 Procent.DataJox
using System;

using System.Collections.Generic;

using System.Text;

using System.Data;

using System.ComponentModel;

using System.Data.SqlClient;

namespace Procent.DataJox

{

public class Northwind : IDisposable

{

private bool disposed = false;
public DataSet GetAllCustomers()

{

using(Open());

// some code here to get data

}

private void Open()

{

string connstr =
"server=localhost;database=northwind;trusted_conne ction=true;";

SqlConnection dbconn = new SqlConnection(connstr);

}

private void Dispose()

{

Dispose(true);
}

private void Dispose(bool disposing)

{

if (!this.disposed)

{

if (disposing)

{

component.Dispose();

}

CloseHandle(handle);

handle = IntPtr.Zero;

}

disposed = true;

}

~Northwind()

{

Dispose(false);

}

}
}
Nov 17 '05 #1
1 2425
Hi,

Why you need to implement IDIsposable?

The error is saying clearly your problem, the Dispose method is not
implemented, you declared it as private when it has to be public ( the one
with no parameters)

if you are using VS when you declare the class and set what interfaces you
are going to implement the IDE will give you an option to expand the methods
you need to implement, use it when possible
cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Lasse Edsvik" <la***@nospam.com> wrote in message
news:ui**************@TK2MSFTNGP11.phx.gbl...
Hello

I'm trying to create a class that uses northwind database and use the
IDisposable interface thingy :)

Can someone explain why I get:

Error 1 'Procent.DataJox.Northwind' does not implement interface member
'System.IDisposable.Dispose()' C:\Documents and Settings\Administrator\My
Documents\Visual Studio 2005\Projects\DataJox\DataJox\Class1.cs 10 18
Procent.DataJox

and (on the using(Open()) row):

Warning 2 Possible mistaken empty statement C:\Documents and
Settings\Administrator\My Documents\Visual Studio
2005\Projects\DataJox\DataJox\Class1.cs 16 26 Procent.DataJox
using System;

using System.Collections.Generic;

using System.Text;

using System.Data;

using System.ComponentModel;

using System.Data.SqlClient;

namespace Procent.DataJox

{

public class Northwind : IDisposable

{

private bool disposed = false;
public DataSet GetAllCustomers()

{

using(Open());

// some code here to get data

}

private void Open()

{

string connstr =
"server=localhost;database=northwind;trusted_conne ction=true;";

SqlConnection dbconn = new SqlConnection(connstr);

}

private void Dispose()

{

Dispose(true);
}

private void Dispose(bool disposing)

{

if (!this.disposed)

{

if (disposing)

{

component.Dispose();

}

CloseHandle(handle);

handle = IntPtr.Zero;

}

disposed = true;

}

~Northwind()

{

Dispose(false);

}

}
}

Nov 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: JP | last post by:
Ok, Im at my wits end with trying to dispose of this class. Everything I try either doesnt dispose the class or I get build error. Im using C#. What Im I doing wrong? XHTML_Library...
117
by: Peter Olcott | last post by:
www.halting-problem.com
28
by: Jon Davis | last post by:
If I have a class with a virtual method, and a child class that overrides the virtual method, and then I create an instance of the child class AS A base class... BaseClass bc = new ChildClass();...
9
by: Alvin Bruney [MVP] | last post by:
with the using construct, exit from scope calls dispose on said object. But what happens in a connection pooling scenario? Is the run-time smart enough to realize that Object Pooling is being used...
15
by: Sam Sungshik Kong | last post by:
Hello! A disposable object's Dispose() method can be called either explicitly by the programmer or implicitly during finalization. If you call Dispose, the unmanaged resources are released...
3
by: trialproduct2004 | last post by:
hi all can some one tell me how to call dispose method of webresponse. I am currently using close method. But this is creating problem. So i want to use dispose method of webresponse. Can some...
6
by: Ammar | last post by:
Dear All, I'm facing a small problem. I have a portal web site, that contains articles, for each article, the end user can send a comment about the article. The problem is: I the comment length...
16
by: Dany | last post by:
Our web service was working fine until we installed .net Framework 1.1 service pack 1. Uninstalling SP1 is not an option because our largest customer says service packs marked as "critical" by...
2
by: Mike Collins | last post by:
I cannot get the correct drop down list value from a drop down I have on my web form. I get the initial value that was loaded in the list. It was asked by someone else what the autopostback was...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.