IDispose problem


L

Lasse Edsvik

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_connection=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);

}

}


}
 
Ad

Advertisements

I

Ignacio Machin \( .NET/ C# MVP \)

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,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top