Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 2nd, 2004, 04:58 PM
Authorized User
 
Join Date: Nov 2004
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Default Query with a *

Hi my problem is that I want to make a query were I can use the * functionnality. I create a query with LIKE [parameter] from access Im able to make a query like *a* and it return all the topic with the letter "a" but if I use my query with my asp code it return nothing WHY???.

My code is quite the same as in the Active Server Page 3.0 book

If I write "Q*" it return nothing instead of all the director beginning with a Q as Quentin Tarantino.

Why and how can I solve that

Thank you very much

Johnjohn

See the code...

<%
  Dim objRS, objComm, objParam, strDirector
  Set objComm = Server.CreateObject("ADODB.Command")

  objComm.ActiveConnection = strConnect ' fill in the command properties
  objComm.CommandText = "qryFilmsByDirector"
  objComm.CommandType = adCmdStoredProc

  ' now the parameters (actually, there's only one parameter here)
  Set objParam = _
     objComm.CreateParameter("Required Director", adVarChar, adParamInput, 50)
  objComm.Parameters.Append objParam

'************************************************* ***
  strDirector = "Q*" '"Quentin Tarantino"
'************************************************* ***
  objComm.Parameters("Required Director") = strDirector

  Set objRS = objComm.Execute ' execute the command and generate the recordset

  Set objComm = Nothing ' don't need the Command and Parameter objects
  Set objParam = Nothing ' ... so we can clean them up

  Response.Write "<H2>Films by " & strDirector & ":</H2>"
  While Not objRS.EOF ' now loop through the records
    Response.Write objRS("Title") & ", directed by " & objRS("Director") & "<BR>"
    objRS.MoveNext
  Wend

  objRS.Close ' now close and clean up
  Set objRS = Nothing
%>



If I write "Q*" it return nothing instead of all the director beginning with a Q.

Why and how can I solve that

Thank you very much

Johnjohn

 
Old November 2nd, 2004, 06:56 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

You should be using % instead of * if you wanted to use LIKE operator.

Cheers!

_________________________
- Vijay G
Strive for Perfection
 
Old November 3rd, 2004, 10:07 AM
Authorized User
 
Join Date: Nov 2004
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you but Q% still dont work.

I dont understand why its so complicated, it seems to me that its a very important feature for any kind of query...

So I hope someone will be able to tell me how to do this.

Thank you

 
Old November 3rd, 2004, 06:06 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,110
Thanks: 0
Thanked 3 Times in 3 Posts
Default

SELECT * FROM <table_name> WHERE <column_name> LIKE 'Q%';

 
Old November 3rd, 2004, 08:59 PM
Registered User
 
Join Date: Dec 2003
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

SELECT * FROM <table_name> WHERE <column_name> LIKE "*Q*"


 
Old November 4th, 2004, 05:36 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

John,

Did that solve the problem by anychance?

_________________________
- Vijay G
Strive for Perfection





Similar Threads
Thread Thread Starter Forum Replies Last Post
Output Query to txt file from SQL Query everest SQL Server 2005 4 November 22nd, 2007 01:49 AM
how to make a query from an existing query raport SQL Language 3 November 13th, 2006 08:59 PM
I solved insert query.now see this Update Query. [email protected] VB.NET 2002/2003 Basics 2 September 21st, 2006 12:48 AM
Syntax error in query. Incomplete query clause. dispickle ADO.NET 3 April 16th, 2004 01:04 PM
Error on Make-Table Query In Union Query rylemer Access 1 August 20th, 2003 07:42 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.