Forum Moderators: open

Message Too Old, No Replies

LIKE statements in ASP.NET?

Can't find out how to write a LIKE statement in ASP.NET. Help!

         

Barrett

8:27 pm on Jun 22, 2004 (gmt 0)

10+ Year Member



I've looked everywhere and can't find out how to write a LIKE statement in ASP.NET. I'm using Dreamweaver MX. Help!

Here's the code I'm working with:

<MM:DataSet
id="DataSet1"
runat="Server"
IsStoredProcedure="false"
ConnectionString='<%# System.Configuration.ConfigurationSettings.AppSettings("MM_CONNECTION_STRING_DocumentationServices") %>'
DatabaseType='<%# System.Configuration.ConfigurationSettings.AppSettings("MM_CONNECTION_DATABASETYPE_DocumentationServices") %>'
CommandText='<%# "SELECT dbo.tblChanges.EC, dbo.tblChanges.ICode, dbo.tblChanges.Change FROM dbo.tblChanges WHERE dbo.tblChanges.ICode = @reportInput " %>'
Debug="true"
>
<Parameters>
<Parameter Name="@reportInput" Value='<%# IIf((Request.Form("reportInput") <> Nothing), Request.Form("reportInput"), "") %>' Type="NChar" />
</Parameters>
</MM:DataSet>

TheNige

11:25 pm on Jun 22, 2004 (gmt 0)

10+ Year Member



LIKE statements are used in SQL syntax.

select * from table where field LIKE '%test%'

remove % character to match beginning or end.

Barrett

12:20 am on Jun 23, 2004 (gmt 0)

10+ Year Member



Okay. But how does that work with input from a form?

duckhunter

4:18 pm on Jun 23, 2004 (gmt 0)

10+ Year Member



Use the Instr function

If Instr(VariableName,"search string") > 0 Then
.... It's True
End If

Or

Dim lPosition

lPosition = Instr(VariableName,"search string")
will give you the position at which "search string" starts