Home All Groups Group Topic Archive Search About
Author
4 Oct 2006 2:14 PM
Umberto Coppolino
Hi,
in ASP I make my search in 3 different types: partial search (with SQL
instruction "... LIKE '%text%'"), initial search (with SQL instruction "...
LIKE 'text%'") or integral search (with SQL instruction "... = 'text'").
Then I make my query string in this way:

<%
SearchType = Request.Form("Type") ' from ListBox
Select Case SearchType
    Case 1 ' partial search
        QueryStr = " WHERE Name LIKE '%" & Request.Form("Name") & "%'"
    Case 2 ' initial search
        QueryStr = " WHERE Name LIKE '" & Request.Form("Name") & "%'"
    Case 3 ' integral search
        QueryStr = " WHERE Name = '" & Request.Form("Name") & "'"
End Select
%>

and then I make the rsCustomer.Source ...

<%
set rsCustomer = Server.CreateObject("ADODB.Recordset")
rsCustomer.ActiveConnection = MM_Farm_String
rsCustomer.Source = "SELECT *  FROM dbo.Customer " & QueryStr
rsCustomer.CursorType = 0
rsCustomer.CursorLocation = 2
rsCustomer.LockType = 3
rsCustomer.Open()
%>

I'll like to make it in ASP .NET. How can I do it?

Best regards.

Umberto

Author
4 Oct 2006 5:19 PM
Brennan Stehling
This is a very general question to a simple problem.  You can use
VB.NET and ADO.NET to run your query against the database.  In this
case I may use the SqlDataSource.

http://msdn2.microsoft.com/en-us/library/xt50s8kz.aspx

Of course you could set up a DataSet and add your various queries to
it.  There are many ways you can do this with ADO.NET.

Brennan Stehling
http://brennan.offwhite.net/blog/


Umberto Coppolino wrote:
Show quoteHide quote
> Hi,
> in ASP I make my search in 3 different types: partial search (with SQL
> instruction "... LIKE '%text%'"), initial search (with SQL instruction "...
> LIKE 'text%'") or integral search (with SQL instruction "... = 'text'").
> Then I make my query string in this way:
>
> <%
> SearchType = Request.Form("Type") ' from ListBox
> Select Case SearchType
>     Case 1 ' partial search
>         QueryStr = " WHERE Name LIKE '%" & Request.Form("Name") & "%'"
>     Case 2 ' initial search
>         QueryStr = " WHERE Name LIKE '" & Request.Form("Name") & "%'"
>     Case 3 ' integral search
>         QueryStr = " WHERE Name = '" & Request.Form("Name") & "'"
> End Select
> %>
>
> and then I make the rsCustomer.Source ...
>
> <%
>  set rsCustomer = Server.CreateObject("ADODB.Recordset")
>  rsCustomer.ActiveConnection = MM_Farm_String
>  rsCustomer.Source = "SELECT *  FROM dbo.Customer " & QueryStr
>  rsCustomer.CursorType = 0
>  rsCustomer.CursorLocation = 2
>  rsCustomer.LockType = 3
>  rsCustomer.Open()
> %>
>
> I'll like to make it in ASP .NET. How can I do it?
>
> Best regards.
>
> Umberto