Using Data Access Application Block for .NET 2.0

DAAB definitely saves the lines of codes to be written for data access. The sample provided below doesn’t include DAAB, but some general codes in .net 2.0 for data access:

       string connectionString = (string)ConfigurationSettings.AppSettings["ConnectionString"];

       SqlConnection connection = new SqlConnection(connectionString);

       SqlCommand command = new SqlCommand("INSERT_PERSON", connection);

       command.CommandType = CommandType.StoredProcedure;

       command.Parameters.Add(new SqlParameter("@Name", SqlDbType.NVarChar, 50));

       command.Parameters["@Name"].Value = "Ashraf";

       command.Parameters.Add(new SqlParameter("@Age", SqlDbType.NVarChar, 10));

       command.Parameters["@Age"].Value = "27";

       connection.Open();

       command.ExecuteNonQuery();

       connection.Close();

 The task can be done using DAAB very simply:

 //using Microsoft.ApplicationBlocks.Data;

 SqlHelper.ExecuteNonQuery(connection,"INSERT_PERSON", new  SqlParameter("@Name","Ashraf") , new SqlParameter("@Age", "27") );

  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati
Print | posted on Friday, July 07, 2006 3:53 PM

Feedback

# re: Using Data Access Application Block for .NET 2.0

left by james at 1/5/2010 8:54 PM Gravatar
how to create dll for c# window application?
Post A Comment
Title:
Name:
Email:
Website:
Comment:
Verification: