-----Message d'origine-----
De : Alexandre Zglav [mailto:[EMAIL PROTECTED]]
Envoyé : dimanche, 23. juin 2002 23:07
À : [EMAIL PROTECTED]
Objet : MySQL Query using ASP


Hi all !

once again thanks for the help you provide me by being so active on this
mailing list :)

I have a litle problem querying a MySQL DB using an ASP script .

Everything works perfectly with my DSN and ODBC driver ( MyODBC ) and I can
access the entries of a MySQL DB quite easely using an ASP script with
simple queries.

Now I am having big trouble when querying a variable.

Let me explain .

Here is a piece of code I use to get the entries in a table using a WHERE
clause and a LIKE clause :


<% @language="VBSCRIPT" %>
<% Option Explicit %>
<HTML>
<HEAD>
<TITLE>HFT MOBILE FOREIGN EXCHANGE CONVERTER</TITLE>
</HEAD>
<BODY>
<BR><BR><BR><BR><BR><CENTER>

<%

set ConnObj=Server.CreateObject("ADODB.Connection")

ConnObj.open "PQATEST"

' This is the querry I use
set RecordSet= ConnObj.execute("SELECT CurrencyA, RatetoCHF FROM data WHERE
CurrencyA Like ' CHF%' ")

If (NOT RecordSet.EOF) Then RecordSet.MoveFirst


 While (NOT RecordSet.EOF)
  Response.write(FormatNumber(RecordSet("RatetoCHF"),6))
  Response.write("<BR>")
  RecordSet.MoveNext
 wend

ConnObj.close
set ConnObj=nothing
%>

</CENTER>
</BODY>
</HTML>


Ok this querry works perfectly and I get back all the enties where CurrencyA
is Like 'CHF'

Now what  If I try a variant like this one :

' Same as before so dont bother ...  :)
<% @language="VBSCRIPT" %>
<% Option Explicit %>
<HTML>
<HEAD>
<TITLE>HFT MOBILE FOREIGN EXCHANGE CONVERTER</TITLE>
</HEAD>
<BODY>
<BR><BR><BR><BR><BR><CENTER>

<%

' ok now lets define a variable
dim CurrencyA

'Lets assign a value to it ( note that the value will be given by a
formulary in a web page )
CurrencyA = "CHF"


'Same as before
set ConnObj=Server.CreateObject("ADODB.Connection")

ConnObj.open "PQATEST"

'Now here is my new querry. I'm getting the value of variable CurrencyA with
concatenation.  ( This works perfect with Access )

set RecordSet= ConnObj.execute("SELECT CurrencyA, RatetoCHF FROM data WHERE
CurrencyA Like ' " & CurrencyA & " '% ")


' Same as before blablabla
If (NOT RecordSet.EOF) Then RecordSet.MoveFirst


 While (NOT RecordSet.EOF)
  Response.write(FormatNumber(RecordSet("RatetoCHF"),6))
  Response.write("<BR>")
  RecordSet.MoveNext
 wend

ConnObj.close
set ConnObj=nothing
%>

</CENTER>
</BODY>
</HTML>


Now here is the error message I get in the generated webpage

Microsoft OLE DB Provider for ODBC Drivers error '80040e09'
[TCX][MyODBC]You have an error in your SQL syntax near '' at line 1
/PQA/test.asp, line 19
I just dont get where the problem is as I'm quite used to do it this way
with M$ Access .  It seems that MySQL gets the " character as a part of the
LIKE statement and IT SHOULDNT !! ....
Well I'm quite despaired now, going to bed after hours of research in all
the forums out there, hoping that tomorow some nice People like you will
have answered me .
Thanks a lot in advance and see ya :)
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.365 / Virus Database: 202 - Release Date: 24.05.2002


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to