473,396 Members | 1,892 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Trouble with ORDER BY clause

Hi all

I'm not sure ASP is the problem, but my SQL statement seems fine to me.

This works fine :
strSQL = "SELECT [_RechPat].* FROM _RechPat INNER JOIN NivPatri ON
[_RechPat].cod_niv = NivPatri.cod_niv WHERE NivPatri.position=2"
set rs = CreateRecordset(strSQL)

This doesn't work :
strSQL = "SELECT [_RechPat].* FROM _RechPat INNER JOIN NivPatri ON
[_RechPat].cod_niv = NivPatri.cod_niv WHERE NivPatri.position=2 ORDER BY
[_RechPat].cod_patrim ASC"
set rs = CreateRecordset(strSQL)

Error Number : -2147467259
Error Description : Unspecified Error (in french : Erreur non spécifiée)
1. ORDER BY clauses work fine in some other recordsets.
2. This SQL statement works fine ( i design and test my SQL queries with MS
ACCESS)
3. Database is MS ACCESS 2000
4. Server = IIS 5.0

Any ideas ?

Jul 19 '05 #1
15 2779
Peroq wrote:
Hi all

I'm not sure ASP is the problem, but my SQL statement seems fine to
me.

This works fine :
strSQL = "SELECT [_RechPat].* FROM _RechPat INNER JOIN NivPatri ON
[_RechPat].cod_niv = NivPatri.cod_niv WHERE NivPatri.position=2"
set rs = CreateRecordset(strSQL)

This doesn't work :
strSQL = "SELECT [_RechPat].* FROM _RechPat INNER JOIN NivPatri ON
[_RechPat].cod_niv = NivPatri.cod_niv WHERE NivPatri.position=2 ORDER
BY [_RechPat].cod_patrim ASC"
set rs = CreateRecordset(strSQL)

Error Number : -2147467259
Error Description : Unspecified Error (in french : Erreur non
spécifiée)
1. ORDER BY clauses work fine in some other recordsets.
2. This SQL statement works fine ( i design and test my SQL queries
with MS ACCESS)
3. Database is MS ACCESS 2000
4. Server = IIS 5.0

Any ideas ?


The first step is to "response.write strsql" so you can verify that the sql
statement string has been created correctly.

If the response.written string is a valid sql statement that can be executed
with no problem in the Access Query Builder, then I suspect a reserved word
problem. Try bracketing the cod_patrim field name: " ...
[_RechPat].[cod_patrim] ASC"

HTH,
Bob Barrows
PS. I urge you to avoid using * in your select list, because ADO has to make
an extra trip to the database to get the column names, impairing the
performance of the application. You should specify the names of the columns
you wish the query to return.
--
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.
Jul 19 '05 #2
I don't see any issues. I suggest installing the latest version of MDAC
and/or making sure you're using an OLEDB driver to connect to your database,
as opposed to ODBC.

Ray at work

"Peroq" <fr*****@yahoo.com> wrote in message
news:3f***********************@nan-newsreader-01.noos.net...
Hi all

I'm not sure ASP is the problem, but my SQL statement seems fine to me.

This works fine :
strSQL = "SELECT [_RechPat].* FROM _RechPat INNER JOIN NivPatri ON
[_RechPat].cod_niv = NivPatri.cod_niv WHERE NivPatri.position=2"
set rs = CreateRecordset(strSQL)

This doesn't work :
strSQL = "SELECT [_RechPat].* FROM _RechPat INNER JOIN NivPatri ON
[_RechPat].cod_niv = NivPatri.cod_niv WHERE NivPatri.position=2 ORDER BY
[_RechPat].cod_patrim ASC"
set rs = CreateRecordset(strSQL)

Error Number : -2147467259
Error Description : Unspecified Error (in french : Erreur non spécifiée)
1. ORDER BY clauses work fine in some other recordsets.
2. This SQL statement works fine ( i design and test my SQL queries with MS ACCESS)
3. Database is MS ACCESS 2000
4. Server = IIS 5.0

Any ideas ?

Jul 19 '05 #3
Thanks bob and ray for your answers.

But for the moment, it still doesn't work.

"Peroq" <fr*****@yahoo.com> a écrit dans le message de
news:3f***********************@nan-newsreader-01.noos.net...
Hi all

I'm not sure ASP is the problem, but my SQL statement seems fine to me.

This works fine :
strSQL = "SELECT [_RechPat].* FROM _RechPat INNER JOIN NivPatri ON
[_RechPat].cod_niv = NivPatri.cod_niv WHERE NivPatri.position=2"
set rs = CreateRecordset(strSQL)

This doesn't work :
strSQL = "SELECT [_RechPat].* FROM _RechPat INNER JOIN NivPatri ON
[_RechPat].cod_niv = NivPatri.cod_niv WHERE NivPatri.position=2 ORDER BY
[_RechPat].cod_patrim ASC"
set rs = CreateRecordset(strSQL)

Error Number : -2147467259
Error Description : Unspecified Error (in french : Erreur non spécifiée)
1. ORDER BY clauses work fine in some other recordsets.
2. This SQL statement works fine ( i design and test my SQL queries with MS ACCESS)
3. Database is MS ACCESS 2000
4. Server = IIS 5.0

Any ideas ?

Jul 19 '05 #4
Did you upgrade MDAC? Also, what does your connection string look like?

Ray at work

"Peroq" <fr*****@yahoo.com> wrote in message
news:3f**********************@nan-newsreader-02.noos.net...
Thanks bob and ray for your answers.

But for the moment, it still doesn't work.

Jul 19 '05 #5
The SQL string (with response.write) :
SELECT [_RechPat].* FROM _RechPat INNER JOIN NivPatri ON [_RechPat].cod_niv
= NivPatri.cod_niv WHERE NivPatri.position=2 ORDER BY
[_RechPat].[cod_patrim]

Error occurs when trying to open the recordset

Jul 19 '05 #6
When you paste this into the SQL query window in Access and run it, what
error do you get?

Ray at work

"Peroq" <fr*****@yahoo.com> wrote in message
news:3f**********************@nan-newsreader-02.noos.net...
The SQL string (with response.write) :
SELECT [_RechPat].* FROM _RechPat INNER JOIN NivPatri ON [_RechPat].cod_niv = NivPatri.cod_niv WHERE NivPatri.position=2 ORDER BY
[_RechPat].[cod_patrim]

Error occurs when trying to open the recordset

Jul 19 '05 #7
1. I didn't update the MDAC yet.

2. Here is my connection string :
Set Conn = Server.createobject("ADODB.Connection")
Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Site Web
T&P\Technique & Patrimoine 2000.mdb;User ID=admin;"

3. When i put this SQL string in ACCESS 2000, it works fine.

"Ray at <%=sLocation%>" <myfirstname at lane34 dot com> a écrit dans le
message de news:%2*****************@TK2MSFTNGP10.phx.gbl...
When you paste this into the SQL query window in Access and run it, what
error do you get?

Ray at work

"Peroq" <fr*****@yahoo.com> wrote in message
news:3f**********************@nan-newsreader-02.noos.net...
The SQL string (with response.write) :
SELECT [_RechPat].* FROM _RechPat INNER JOIN NivPatri ON

[_RechPat].cod_niv
= NivPatri.cod_niv WHERE NivPatri.position=2 ORDER BY
[_RechPat].[cod_patrim]

Error occurs when trying to open the recordset


Jul 19 '05 #8
Is your Access database password[less] protected? You're passing a userid
but no password. Try passing both or neither.

If that doesn't help, fire the person who created that directory structure
and then put the database in a path without spaces or other nonsensical
characters.

Ray at work

"Peroq" <fr*****@yahoo.com> wrote in message
news:3f***********************@nan-newsreader-03.noos.net...
1. I didn't update the MDAC yet.

2. Here is my connection string :
Set Conn = Server.createobject("ADODB.Connection")
Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Site Web
T&P\Technique & Patrimoine 2000.mdb;User ID=admin;"

3. When i put this SQL string in ACCESS 2000, it works fine.

"Ray at <%=sLocation%>" <myfirstname at lane34 dot com> a écrit dans le
message de news:%2*****************@TK2MSFTNGP10.phx.gbl...
When you paste this into the SQL query window in Access and run it, what
error do you get?

Ray at work

"Peroq" <fr*****@yahoo.com> wrote in message
news:3f**********************@nan-newsreader-02.noos.net...
The SQL string (with response.write) :
SELECT [_RechPat].* FROM _RechPat INNER JOIN NivPatri ON

[_RechPat].cod_niv
= NivPatri.cod_niv WHERE NivPatri.position=2 ORDER BY
[_RechPat].[cod_patrim]

Error occurs when trying to open the recordset



Jul 19 '05 #9
I just can't fire myself :)

I updated to MDAC 2.8. nothing better.

My database connection works fine as almost 100 recordset work with it.
I tested the ORDER BY clause on a simple query : it worked fine.
But with this one it doesn't work.

The odd is that error description : "undefined" ???

BTW, are you at work ?
If yes, where are you from cause where i live (France), it's 9 PM.
Kind of late to work ! (i work at home)

"Ray at <%=sLocation%>" <myfirstname at lane34 dot com> a écrit dans le
message de news:Of**************@tk2msftngp13.phx.gbl...
Is your Access database password[less] protected? You're passing a userid
but no password. Try passing both or neither.

If that doesn't help, fire the person who created that directory structure
and then put the database in a path without spaces or other nonsensical
characters.

Ray at work

"Peroq" <fr*****@yahoo.com> wrote in message
news:3f***********************@nan-newsreader-03.noos.net...
1. I didn't update the MDAC yet.

2. Here is my connection string :
Set Conn = Server.createobject("ADODB.Connection")
Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Site Web
T&P\Technique & Patrimoine 2000.mdb;User ID=admin;"

3. When i put this SQL string in ACCESS 2000, it works fine.

"Ray at <%=sLocation%>" <myfirstname at lane34 dot com> a écrit dans le
message de news:%2*****************@TK2MSFTNGP10.phx.gbl...
When you paste this into the SQL query window in Access and run it, what error do you get?

Ray at work

"Peroq" <fr*****@yahoo.com> wrote in message
news:3f**********************@nan-newsreader-02.noos.net...
> The SQL string (with response.write) :
> SELECT [_RechPat].* FROM _RechPat INNER JOIN NivPatri ON
[_RechPat].cod_niv
> = NivPatri.cod_niv WHERE NivPatri.position=2 ORDER BY
> [_RechPat].[cod_patrim]
>
> Error occurs when trying to open the recordset
>
>
>



Jul 19 '05 #10
I don't know what else to tell you. One other suggestion is to bracket
everything instead of just some of the things. ? I hate the unspecified
errors...

Sorry! Don't fire yourself.

I am at work, but in PA, USA. I'm munching on Freedom Fries as I work. ;]

Ray at work

"Peroq" <fr*****@yahoo.com> wrote in message
news:3f***********************@nan-newsreader-01.noos.net...
I just can't fire myself :)

I updated to MDAC 2.8. nothing better.

My database connection works fine as almost 100 recordset work with it.
I tested the ORDER BY clause on a simple query : it worked fine.
But with this one it doesn't work.

The odd is that error description : "undefined" ???

BTW, are you at work ?
If yes, where are you from cause where i live (France), it's 9 PM.
Kind of late to work ! (i work at home)

Jul 19 '05 #11
Peroq wrote:
Thanks bob and ray for your answers.

But for the moment, it still doesn't work.

I think we need to see the code used to open the recordset.

Bob Barrows

--
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.
Jul 19 '05 #12
I finally found it....

Bob advice was good.
Something was wrong with the reserved words.

I focused on the ORDER BY clause, and the problem was in the WHERE clause
("position" is a reserved word)

I was so sure to have tested that SQL string with that WHERE clause !

Finally, i had a big trouble because of a very small and simple error !

Thanks for helping me.
Sorry to have bothered you with such a silly error.

Have a nice day.

BTW : did all american people really rename the french fries ?

"Ray at <%=sLocation%>" <myfirstname at lane34 dot com> a écrit dans le
message de news:uX**************@TK2MSFTNGP12.phx.gbl...
I don't know what else to tell you. One other suggestion is to bracket
everything instead of just some of the things. ? I hate the unspecified
errors...

Sorry! Don't fire yourself.

I am at work, but in PA, USA. I'm munching on Freedom Fries as I work. ;]
Ray at work

"Peroq" <fr*****@yahoo.com> wrote in message
news:3f***********************@nan-newsreader-01.noos.net...
I just can't fire myself :)

I updated to MDAC 2.8. nothing better.

My database connection works fine as almost 100 recordset work with it.
I tested the ORDER BY clause on a simple query : it worked fine.
But with this one it doesn't work.

The odd is that error description : "undefined" ???

BTW, are you at work ?
If yes, where are you from cause where i live (France), it's 9 PM.
Kind of late to work ! (i work at home)


Jul 19 '05 #13

"Peroq" <fr*****@yahoo.com> wrote in message
news:3f**********************@nan-newsreader-02.noos.net...

BTW : did all american people really rename the french fries ?


Nah, I don't think so. We just stopped eating them or believing that they
exist at all. ;] And we now freedom-kiss our wives, too. d:

Ray at work
Jul 19 '05 #14
so the essential remains.

See ya.

"Ray at <%=sLocation%>" <myfirstname at lane34 dot com> a écrit dans le
message de news:eL**************@TK2MSFTNGP10.phx.gbl...

"Peroq" <fr*****@yahoo.com> wrote in message
news:3f**********************@nan-newsreader-02.noos.net...

BTW : did all american people really rename the french fries ?


Nah, I don't think so. We just stopped eating them or believing that they
exist at all. ;] And we now freedom-kiss our wives, too. d:

Ray at work

Jul 19 '05 #15
Thanks Bob. You were right.
position was a reserved word.

see ya.

"Bob Barrows" <re******@NOyahoo.SPAMcom> a écrit dans le message de
news:eP**************@tk2msftngp13.phx.gbl...
Peroq wrote:
Thanks bob and ray for your answers.

But for the moment, it still doesn't work.

I think we need to see the code used to open the recordset.

Bob Barrows

--
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.

Jul 19 '05 #16

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: M Wells | last post by:
Hi all, Just wondering if anyone can tell me if an order by clause on a select query would have any impact on the time it takes to retrieve results? Essentially I'm selecting Top 1 out of a...
7
by: JJ_377 | last post by:
Can someone tell me why SQL seems to ignore my order by clause? I tried to run through the debugger, but the debugger stops at the select statement line and then returns the result set; so, I have...
5
by: Geremy | last post by:
Hi Consider two tables id1 code1 ----------- ----- 1 a 2 b 3 c id2 code2 value
1
by: mailar | last post by:
Hi, Can I use ORDER BY clause in my sql UDF that returns a table and has the folloing body. (trial_udf.sql) drop function aa@ create function aa() returns TABLE(empno varchar(20)) language...
2
by: New Guy | last post by:
I created this query in Access with the Design View. SELECT Fiscal_Period.FiscalKey, Invoice.type, Invoice.accid, Sum(Invoice.Total) AS Amount FROM Fiscal_Period LEFT JOIN Invoice ON...
3
by: Student at college | last post by:
Something is wrong with my report in Access. In the query for the report I have an order by clause. However, when I run the report, it comes out in a different order. Is there something else...
26
by: GreatAlterEgo | last post by:
Hi, This is my query which is embedded in a COBOL program. EXEC SQL SELECT DATE, AGE, DURATION, AMT INTO :LDATE, :L.AGE, :L.DURATION, :L.AMT FROM TAB1 WHERE CODE = :KEY.CODE AND...
104
by: Beowulf | last post by:
I have the view below and if I use vwRouteReference as the rowsource for a combo box in an MS Access form or run "SELECT * FROM vwRouteReference" in SQL Query Analyzer, the rows don't come through...
59
by: Rico | last post by:
Hello, I have an application that I'm converting to Access 2003 and SQL Server 2005 Express. The application uses extensive use of DAO and the SEEK method on indexes. I'm having an issue when...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.