[thelist] ASP.NET 2.0 and MSSQL - using 'like' with Int32

Ken Schaefer Ken at adOpenStatic.com
Mon Sep 17 09:10:26 CDT 2007

-----Original Message-----
From: thelist-bounces at lists.evolt.org [mailto:thelist-bounces at lists.evolt.org] On Behalf Of Joel D Canfield
Sent: Monday, 17 September 2007 11:33 PM
To: thelist at lists.evolt.org
Subject: Re: [thelist] ASP.NET 2.0 and MSSQL - using 'like' with Int32

> > Can you provide a greater code snippet please (and also the
> > SQL Server version you are using)?
> <asp:SqlDataSource
>     ID="srcDIDs"
>     runat="server"
>     ConnectionString="<%$ ConnectionStrings:cnxHelm %>"
>     FilterExpression="CONVERT(did,'System.String') like '%{0}%'"
>     ProviderName="System.Data.SqlClient"
>     SelectCommand="select did from dids">
>     <FilterParameters>
>         <asp:ControlParameter
>             ControlID="SearchTerm"
>             Name="did"
>             PropertyName="Text" />
>     </FilterParameters>
> </asp:SqlDataSource>

Hmm - I don't know enough about declarative data sources to know what's happening here. Let me repro your setup, then we can check SQL Profiler to see what's being sent to SQL Server.

> > but perhaps it has an overloaded signature that allows you to
> > use the way you are using it.
> If that means *I've* set something up to allow this, I assure you I
> haven't ;) If it's important for me to know what that means, please
> explain it, 'cause I don't have a clue what an 'overloaded signature'
> is.

A signature is the parameter list that a class constructor or method (function or subroutine) takes.

An overloaded signature means that there are multiple different parameter lists that the constructure or method can take.

For example if we look at the SqlConnection class in the System.Data.SqlClient namespace:
you can see that there are two constructor signatures:

the first is just:
oSqlConn = New SqlConnection()
(after which you need to set the ConnectionString property)

The second is:
oSqlConn = New SqlConnection(string)
where "string" is a connection string to a SQL server.

In Visual Studio, when you have a constructor or method, when using Intellisense in code view you will see a "1 of x" with little up/down arrows. Clicking those arrows show you the various constructor/method signatures.

If you create your own class, then in VB you'd use the "Overloads" keyword:

Function Overloads myFunction() as String
        ' Do stuff
End Function

Function Overloads myFunction(ByVal String1 As string) As String
        ' Do stuff
End Function

Function Overloads myFunction(ByVal String1 As String, ByVal String2 As String) as String
        ' Do stuff
End Function

VB.NET has an advantage over C# in that it supports optional parameters, which allows you to reduce the number of signatures that you need to create:

Function myFunction(ByVal String1 As String, ByVal Optional string2 = "Hello World") as String
        ' Do stuff
End Function



More information about the thelist mailing list