Parameterized Queries
Skip Navigation Links.

Parameterized Queries

Skip Navigation LinksHome :: ASP.NET :: Parameterized Query Class

Create complex parameterized queries with a couple of lines of code!

Parameterized queries are great - mainly because they cannot be script injection attacked. But using parameterized queries has always been difficult. This class wraps up the required functionality in a couple of lines of code to...

  • search most data types in different ways e.g. for string searches you can specify whether you want to match a whole string, any part of a string, a whole word, just the first part of a word, comma delimited strings, or even check plurals too!
  • You can get a 'fully loaded' datareader from the result set with one line of code!
  • Specify AND/OR/AND NOT etc. singly or in grouped clauses and ORDER BY
  • extensive manual support to manipulate the SQL string for those quirky requirements
  • Lookups i.e. return a value (even specify the expected return value). You can get a count of the number of records that will be returned
  • You can even UPDATE records!
  • An easy to call debug function is included
  • You can retrieve the raw SQL, an SqlCommand, or just the WHERE clause
  • you can specify the exact fields to return
  • IDisposable Support included
  • Integrates with my ParameterizedQuery.PagedTable object to get specified pages of records

Sample Code

'instantiate the ParameterizedQuery (specifying 'Customers' as the table we are querying)

Dim pq As New ParameterizedQuery("Customers")

'search the email field for customers with a btinternet email

pq.AddParameter("Email", "btinternet", ParameterizedQuery.ParamType.MatchWholeString)

'specify an ORDER BY - note the case is insensitive -

pq.OrderBy = "CustomerID DESC"


Getting Started

Getting started is easy...

The rest of this page is hidden, you must be a member to view it

To become a member and get immediate access to the course please join here Free!

Already Enrolled? please click here to Login

Next >> Search parameters
top of page
all content ©1996/2012 BennySutton.com
all images © their respective owners This site uses Thumbshots previews