Sqlhelper.vb free download




















RegisterClientScriptBlock this. RegisterClientScriptBlock Me. ExecuteReader Example with SqlHelper class. It returns the SqlDataReader object, which can be used in loop for reading records one by one and also can be directly assigned to a DataSource control.

ExecuteReader constr, CommandType. Text, query ;. DataBind ;. Private Sub BindReader. Text, query. ExecuteDataset Example with SqlHelper class. It returns the DataSet object which can contain single or multiple Tables containing records and can be used to populate controls like GridView, Repeater, etc. ExecuteDataset constr, CommandType. Private Sub BindDataSet.

Tables 0. Related Articles. Add Comments. Thank you for the feedback. The comment is now awaiting moderation. You will be notified via email when the author replies to your comment. Please select a comment to reply. You can add your comment about this article using the form below. Make sure you provide a valid email address else you won't be notified when the author replies to your comment Please note that all comments are moderated and will be deleted if they are Not relavant to the article Spam Advertising campaigns or links to other sites Abusive content.

Please do not post code, scripts or snippets. Required Invalid Email Address. Security code:. Apart from the flexibility provided by ADO.

NET, sometimes we find ourselves repeating the same code again and again. Consider that at some point in our application we need to pass some parameters and retrieve some information from the database. We can perform this task by writing lines of code which is cool.

But when later we need to pass parameters again we have to write those lines again, which is not cool. For this reason Microsoft introduced the Data Access Application Block which can be used to perform common tasks with less code. Another good reason to use the Microsoft. NET Data Access Application Block is that it makes the application consistent, meaning that if different companies are using the Data Access Block then you will find the code more easier to understand.

You can download the Microsoft. Download the Application Block and simply install it. Let's see how we can use it. In this article I have used the Microsoft. Once you download and install the application block you need to refer it in your application. For this first you need to create the. You can simply add the Data Access Application Block project in your current project and build the solution this can also be performed using the command line tools.

Once the solution is built, the. Delete the Data Access Project from your current project as you only need it to create the. And now add a reference in your project which will refer to Microsoft.

Once you have made the reference you are ready to use the Application Block in your project. Let's first see how we can access data without using the Application Block so that we can compare the flexibility of both approaches. Below is a simple example that inserts two parameters into the database. You can note that as the number of parameters increases the lines of code also increases.

As you can see we had to write a lot of code to insert the parameters into the database. Now suppose that you have 10 parameters instead of two, it would take you an hour to write a simple Insert module. Let's see how you can accomplish this using the Microsoft. As you see in the above code we perform the whole operation in a single line instead of writing lines. First of all you should always add the namespace Microsoft. Data without using the namespace you will not be able to use the Application Block.

The next interesting thing that you might note is the SqlHelper class. The SqlHelper class is developed by Microsoft developers which contains the static methods to access the database. You can view the SqlHelper class by opening it in any word editor. Consider a situation that you need to retrieve multiple rows from the database. This retrieval can be for only displaying purposes and you want this task to be completed very fast. Since you only need to display the rows and you need it very fast your best bet is to use SqlDataReader since its a forward only reader.

Lets see how you can use SqlDataReader to get the rows you wanted in an efficient and quick manner. Could not load branches. Could not load tags. This branch is up to date with master. This branch is not ahead of the upstream master.

Open pull request. Latest commit. Git stats commits. Failed to load latest commit information. Added msbuild-by-convention. Feb 26, Nov 13, Apr 20, Initial commit. Dec 1, May 18, Aug 14, View code.



0コメント

  • 1000 / 1000