web 2.0

Microsoft enterprise Library Data Block

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.SqlImports 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) :)

Comments

Aijaz Ahmed Rizwi , on 5/25/2009 12:48:46 AM Said:

Aijaz Ahmed Rizwi

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

Sheikhoo , on 5/25/2009 12:49:58 AM Said:

Sheikhoo

Good stuff... seems excellent.

lunettes montures lentilles United States, on 12/19/2009 5:47:24 AM Said:

lunettes montures lentilles

I was wondering what is up with that weird gravatar??? I know 5am is early and I'm not looking my best at that hour, but I hope I don't look like this! I might however make that face if I'm asked to do 100 pushups. lol

Add comment


(Will show your Gravatar icon)

  Country flag

biuquote
  • Comment
  • Preview
Loading