SqlHelper not available for me / C# + Enterprise Library

N

nycmetro

Hi,

I've been struggling very hard to understand why despite recompiling
and adding references to the Enterprise Library Data Access Application
block, I'm unable to use SqlHelper.
I get the missing assembly reference error.

(The type or namespace name 'SqlHelper' could not be found (are you
missing a using directive
or an assembly reference?))

The reference on top of my code is:

using System;
using Microsoft.Practices.EnterpriseLibrary.Data;
using Microsoft.Practices.EnterpriseLibrary.Common;
using Microsoft.Practices.EnterpriseLibrary.Configuration;
using System.Data;
using System.Data.SqlClient;

I made sure all the three Data, Common Configuration dlls are
referenced properly as well. Yet I'm unable to use SqlHelper. Does
anyone seen the same problem and solved it? Please help with any info
or pointers.

Thank you.

I'm using VS2003 ASP.NET 1.1 SQL Server 2000 on Windows XP with the
latest available application blocks for ASP.NET 1.1 downloaded from
Microsoft.
 
J

Jignesh Desai

Hope you have also added reference to "SQLHelper.dll " ??

Regards
Jignesh Desai
 
N

nycmetro

Hi JD,

Thanks for the response.

But I kid you not, I can't find the SQLHelper.dll in the latest P&P zip
archive. Does this file not ship with Ent P&P anymore?

Thank you again.
 
S

Sericinus hunter

nycmetro said:
Hi JD,

Thanks for the response.

But I kid you not, I can't find the SQLHelper.dll in the latest P&P zip
archive. Does this file not ship with Ent P&P anymore?

The dll used to be called Microsoft.ApplicationBlocks.Data.dll
It might need to be built first.
 
M

Mythran

nycmetro said:
Hi,

I've been struggling very hard to understand why despite recompiling
and adding references to the Enterprise Library Data Access Application
block, I'm unable to use SqlHelper.
I get the missing assembly reference error.

(The type or namespace name 'SqlHelper' could not be found (are you
missing a using directive
or an assembly reference?))

The reference on top of my code is:

using System;
using Microsoft.Practices.EnterpriseLibrary.Data;
using Microsoft.Practices.EnterpriseLibrary.Common;
using Microsoft.Practices.EnterpriseLibrary.Configuration;
using System.Data;
using System.Data.SqlClient;

I made sure all the three Data, Common Configuration dlls are
referenced properly as well. Yet I'm unable to use SqlHelper. Does
anyone seen the same problem and solved it? Please help with any info
or pointers.

Thank you.

I'm using VS2003 ASP.NET 1.1 SQL Server 2000 on Windows XP with the
latest available application blocks for ASP.NET 1.1 downloaded from
Microsoft.

SQLHelper is not part of the Patterns and Practices Enterprise Library. The
P&P guys took the idea behind SQL Helper and expanded upon it to provide
support for more databases as well as more functionality. This is just the
Data Access portion of the EL. They also have the Logging, Security,
Configuration and others. This entire library "suite" is just the
beginning. It also allows for the developer (you) to expand upon it, change
it, modify it, deploy it, at your will.

To use the Data Access layer, you are referencing the correct assemblies as
well as using the correct namespaces, but you need to code differently than
the SQLHelper allowed. Example of using the Data Access AB's:

In your DAL:
DataSet ds = new DataSet();
Database db = DatabaseFactory.CreateDatabase();

// To load data from db into DataSet.
db.LoadDataSet(
CommandType.StoredProcedure,
"ProcedureName",
ds,
new string[] { "TableNameToFill" }
);

// To insert data into db.
db.ExecuteScalar("ProcedureName", new object() { values });
// or
db.ExecuteScalar("ProcedureName", value1, value2, value3, value4);

// Etc...

See the documentation provided with the Enterprise Library for more
information and examples of how to use :)

Unfortunately, the EL guys didn't keep the TypedParams methods. But, with a
little bit of work, you can implement your own :) We did it here in just a
couple of hours, which included learning the layout of the EL as well, and
just overloaded the proper methods of the proper objects we wanted to
provide the functionality in....works great! :)

HTH,
Mythran
 

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