Re: Can"t Get Query to Work

Re: Can"t Get Query to Work

am 24.11.2004 16:42:28 von usenet+mpiad

In article , "Wayne Wengert"
wrote in microsoft.public.inetserver.asp.db:
> The database is Access - it uses * instead of %

It's got nothing to do with the database, it's the access method that
counts.

ADO uses the SQL standard wildcards of _ and %, in all cases.
.

hth

Adam
--
Work expands to fill the time available.
-- Cyril Northcote Parkinson, "The Economist", 1955

Can"t Get Query to Work

am 24.11.2004 16:58:40 von Wayne Wengert

I have an ASP page which connects to an Access database. In my asp page I
build a query to return all records where the bandname begins with a
selected letter. When I try to open the recordset I get the following error
(the actual sql statement is also shown)

SELECT Units.BandName, Units.Class, Units.City, Units.State, Units.WebSite,
Units.Contact, Units.ContactEmail, Units.ContactPhone, Units.BandID FROM
Units WHERE ((Units.BandName) Like "f*") ORDER BY BandName

Microsoft OLE DB Provider for ODBC Drivers error '80040e10'

[Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1.

/wba/UnitRegLogin.asp, line 41



If I copy that SQL into access it works fine? What am I m,issing here?



Wayne

Re: Can"t Get Query to Work

am 24.11.2004 17:14:31 von maarten

I don't know if this resolve the error, try Like "f%"

And why ODBC


"Wayne Wengert" schreef in bericht
news:ehV8J6j0EHA.3840@TK2MSFTNGP10.phx.gbl...
>I have an ASP page which connects to an Access database. In my asp page I
> build a query to return all records where the bandname begins with a
> selected letter. When I try to open the recordset I get the following
> error
> (the actual sql statement is also shown)
>
> SELECT Units.BandName, Units.Class, Units.City, Units.State,
> Units.WebSite,
> Units.Contact, Units.ContactEmail, Units.ContactPhone, Units.BandID FROM
> Units WHERE ((Units.BandName) Like "f*") ORDER BY BandName
>
> Microsoft OLE DB Provider for ODBC Drivers error '80040e10'
>
> [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1.
>
> /wba/UnitRegLogin.asp, line 41
>
>
>
> If I copy that SQL into access it works fine? What am I m,issing here?
>
>
>
> Wayne
>
>

Re: Can"t Get Query to Work

am 24.11.2004 17:17:31 von maarten

Try without ODBC

Connect_String="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
Server.MapPath ("myDatabase.mdb")

Re: Can"t Get Query to Work

am 24.11.2004 17:17:52 von Wayne Wengert

The database is Access - it uses * instead of %

Wayne

"Maarten" wrote in message
news:Hr2pd.34151$fm.1331296@phobos.telenet-ops.be...
>
> I don't know if this resolve the error, try Like "f%"
>
> And why ODBC
>
>
> "Wayne Wengert" schreef in bericht
> news:ehV8J6j0EHA.3840@TK2MSFTNGP10.phx.gbl...
> >I have an ASP page which connects to an Access database. In my asp page I
> > build a query to return all records where the bandname begins with a
> > selected letter. When I try to open the recordset I get the following
> > error
> > (the actual sql statement is also shown)
> >
> > SELECT Units.BandName, Units.Class, Units.City, Units.State,
> > Units.WebSite,
> > Units.Contact, Units.ContactEmail, Units.ContactPhone, Units.BandID FROM
> > Units WHERE ((Units.BandName) Like "f*") ORDER BY BandName
> >
> > Microsoft OLE DB Provider for ODBC Drivers error '80040e10'
> >
> > [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected
1.
> >
> > /wba/UnitRegLogin.asp, line 41
> >
> >
> >
> > If I copy that SQL into access it works fine? What am I m,issing here?
> >
> >
> >
> > Wayne
> >
> >
>
>

Re: Can"t Get Query to Work

am 24.11.2004 17:24:06 von maarten

If its is < 2000 yes otherwise %, maybe ODBC don't accept *
Try to open direct whitout ODBC

Re: Can"t Get Query to Work

am 24.11.2004 17:38:06 von reb01501

Not when you run a query using ADO. You must use the ODBC wildcards, not the
Access wildcards.

However, using the wrong wildcard will just result in not getting any data
returned. It will not raise an error.

Your error is most likely caused by the use of reserved keywords when naming
your database objects (tables and fields.) You should check here,
http://www.aspfaq.com/show.asp?id=2080, to see if any of your field or table
names are reserved. Change the names if you can, otherwise you will need to
remember to bracket the names [] when using them in queryies run by ADO.

Bob Barrows

Wayne Wengert wrote:
> The database is Access - it uses * instead of %
>
> Wayne
>
> "Maarten" wrote in message
> news:Hr2pd.34151$fm.1331296@phobos.telenet-ops.be...
>>
>> I don't know if this resolve the error, try Like "f%"
>>
>> And why ODBC
>>
>>
>> "Wayne Wengert" schreef in bericht
>> news:ehV8J6j0EHA.3840@TK2MSFTNGP10.phx.gbl...
>>> I have an ASP page which connects to an Access database. In my asp
>>> page I build a query to return all records where the bandname
>>> begins with a selected letter. When I try to open the recordset I
>>> get the following error
>>> (the actual sql statement is also shown)
>>>
>>> SELECT Units.BandName, Units.Class, Units.City, Units.State,
>>> Units.WebSite,
>>> Units.Contact, Units.ContactEmail, Units.ContactPhone, Units.BandID
>>> FROM Units WHERE ((Units.BandName) Like "f*") ORDER BY BandName
>>>
>>> Microsoft OLE DB Provider for ODBC Drivers error '80040e10'
>>>
>>> [Microsoft][ODBC Microsoft Access Driver] Too few parameters.
>>> Expected 1.
>>>
>>> /wba/UnitRegLogin.asp, line 41
>>>
>>>
>>>
>>> If I copy that SQL into access it works fine? What am I m,issing
>>> here?
>>>
>>>
>>>
>>> Wayne

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.

Re: Can"t Get Query to Work

am 24.11.2004 17:39:35 von maarten

Try this out:

SELECT
BandName,Class,City,State,WebSite,Contact,ContactEmail,Conta ctPhone,BandID
FROM Units WHERE BandName Like "f*" ORDER BY BandName

Re: Can"t Get Query to Work

am 24.11.2004 18:20:25 von Wayne Wengert

Thanks Bob. That is an excellent resource. I have one reserved name "Class"
so I bracketed it but that made no difference

Wayne

"Bob Barrows [MVP]" wrote in message
news:%23Spo6Pk0EHA.2568@TK2MSFTNGP11.phx.gbl...
> Not when you run a query using ADO. You must use the ODBC wildcards, not
the
> Access wildcards.
>
> However, using the wrong wildcard will just result in not getting any data
> returned. It will not raise an error.
>
> Your error is most likely caused by the use of reserved keywords when
naming
> your database objects (tables and fields.) You should check here,
> http://www.aspfaq.com/show.asp?id=2080, to see if any of your field or
table
> names are reserved. Change the names if you can, otherwise you will need
to
> remember to bracket the names [] when using them in queryies run by ADO.
>
> Bob Barrows
>
> Wayne Wengert wrote:
> > The database is Access - it uses * instead of %
> >
> > Wayne
> >
> > "Maarten" wrote in message
> > news:Hr2pd.34151$fm.1331296@phobos.telenet-ops.be...
> >>
> >> I don't know if this resolve the error, try Like "f%"
> >>
> >> And why ODBC
> >>
> >>
> >> "Wayne Wengert" schreef in bericht
> >> news:ehV8J6j0EHA.3840@TK2MSFTNGP10.phx.gbl...
> >>> I have an ASP page which connects to an Access database. In my asp
> >>> page I build a query to return all records where the bandname
> >>> begins with a selected letter. When I try to open the recordset I
> >>> get the following error
> >>> (the actual sql statement is also shown)
> >>>
> >>> SELECT Units.BandName, Units.Class, Units.City, Units.State,
> >>> Units.WebSite,
> >>> Units.Contact, Units.ContactEmail, Units.ContactPhone, Units.BandID
> >>> FROM Units WHERE ((Units.BandName) Like "f*") ORDER BY BandName
> >>>
> >>> Microsoft OLE DB Provider for ODBC Drivers error '80040e10'
> >>>
> >>> [Microsoft][ODBC Microsoft Access Driver] Too few parameters.
> >>> Expected 1.
> >>>
> >>> /wba/UnitRegLogin.asp, line 41
> >>>
> >>>
> >>>
> >>> If I copy that SQL into access it works fine? What am I m,issing
> >>> here?
> >>>
> >>>
> >>>
> >>> Wayne
>
> --
> Microsoft MVP -- ASP/ASP.NET
> Please reply to the newsgroup. The email account listed in my From
> header is my spam trap, so I don't check it very often. You will get a
> quicker response by posting to the newsgroup.
>
>

Got it working

am 24.11.2004 18:30:40 von Wayne Wengert

I changed the Like expression to 'f%' and that works. I had forgotten that I
have to use ADO syntax even though the DB is Access.

Thanks for the quick and helpful responses.

Wayne

"Wayne Wengert" wrote in message
news:ehV8J6j0EHA.3840@TK2MSFTNGP10.phx.gbl...
> I have an ASP page which connects to an Access database. In my asp page I
> build a query to return all records where the bandname begins with a
> selected letter. When I try to open the recordset I get the following
error
> (the actual sql statement is also shown)
>
> SELECT Units.BandName, Units.Class, Units.City, Units.State,
Units.WebSite,
> Units.Contact, Units.ContactEmail, Units.ContactPhone, Units.BandID FROM
> Units WHERE ((Units.BandName) Like "f*") ORDER BY BandName
>
> Microsoft OLE DB Provider for ODBC Drivers error '80040e10'
>
> [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1.
>
> /wba/UnitRegLogin.asp, line 41
>
>
>
> If I copy that SQL into access it works fine? What am I m,issing here?
>
>
>
> Wayne
>
>