|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Search in .NETin 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 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
Confirm Message in gridview
Object data source, setting parameter source to Page.Partner.Guid User controls and LoadControl method Slow File Upload Speed IIS 6.0 ASP.net 2.0 Newbie ASP.NET question for Webportal project Tree view with XML and Populateondemand How to use .Net controls in regular ASP RowCommand Event of a nested Gridview How to assign access key to MenuItem XPath Asp.net |
|||||||||||||||||||||||