Geeks With Blogs

News

Agha Usman Ahmed JILAWATAN

Hey geeks,
Well ... It is always difficult to understand someone's code which you have writted already. I have written a Library called Data Aceess Tools, which is more like a data block of enterprise library. However, enterprise library is quit advance then Data Aceess Tools, which make my interest to work on enterprise library. so let me give you step by step instrucion. now please dont ask me to define the installations step thats too simple, we have been doing the same installation from childhood. so lets get down to the business.

Step 1 (Adding Enterprise Library to Project):

Geeks, before I start I would like to remind again that this article is will provide only Data Block information that is why we need to register two dlls in out project.

1) Microsoft.Practices.EnterpriseLibrary.Data.Sql  &  Microsoft.Practices.EnterpriseLibrary.Data.

Yes, It is sure very easy. so lets move on.

Step 2 (Coding):

first of all import the foloowing libraries in the class

Imports Microsoft.Practices.EnterpriseLibrary.Data.Sql
Imports Microsoft.Practices.EnterpriseLibrary.Data

Now for creating the connection, Create Database object and pass the connection String in the method.

Dim db As Database = DatabaseFactory.CreateDatabase("Database")

Well in our case we are trying to access Stored procedure, so lets start with that.

Dim DbCommand As Common.DbCommand = db.GetStoredProcCommand(“Sp_writeData“)

now lets add parameters for stored procedure.

db.AddInParameter(DbCommand, "@UserID", DbType.Int32, reportId)
db.AddInParameter(DbCommand,
"@Age", DbType.Int32, reportJobId)
db.AddInParameter(DbCommand,
"@MisInfo", DbType.Xml, parameterXml)

Okay let me define these lines. db is the name of database object by which we are adding parameters. DbCommand is the name of command Object in which we are adding parameters.
Now if this stored procedure returning you result then do the following:

db.ExecuteScalar(DbCommand)

or


Dim dr as SqlClient.SqlDataReader = db.ExecuteReader(DbCommand)

or

Dim ds as DataSet = db.ExecuteDataSet(DbCommand).

here it is ,  now you got the result in your recordset ..... do whatever you want to . (with database) :)

Posted on Thursday, October 5, 2006 8:16 AM | Back to top


Comments on this post: Microsoft enterprise Library Data Block Part 1.

# re: Microsoft enterprise Library Data Block Part 1.
Requesting Gravatar...
Good going----carry on
Left by Shehzad Ahmed on Oct 12, 2006 9:51 AM

# re: Microsoft enterprise Library Data Block Part 1.
Requesting Gravatar...
Thats what I like about this guy ... he always come up with the thing which I need ..... and when you are going to cover the rest of data block and other block of enterprise library
Left by Aijaz Ahmed Rizwi on Dec 23, 2006 7:34 PM

# re: Microsoft enterprise Library Data Block Part 1.
Requesting Gravatar...
Good stuff... seems excellent.
Left by Sheikhoo on Dec 23, 2006 7:35 PM

Your comment:
 (will show your gravatar)


Copyright © Agha Usman Ahmed | Powered by: GeeksWithBlogs.net