Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

invalid descriptor index 1

Status
Not open for further replies.

PavelGur

Programmer
Sep 21, 2001
75
I'm puzled with this error. I have a query in MS Access that works perfectly fine. However when I try to open recordset in VC++ 6.0 with the same query I'm getting "invalid descriptor index" error. Here is the query:

Code:
CString szPLCString = "SELECT TOP 60 C.Stock \
FROM [SELECT B.* FROM Policies AS B ORDER BY B.Stock, B.SellDate DESC]. AS C \
WHERE [SellDate] In (SELECT TOP 1 [SellDate] FROM \
(SELECT B.* FROM Policies AS B \
ORDER BY B.Stock, B.SellDate DESC) WHERE Stock = C.Stock ORDER BY 1 DESC) \
ORDER BY B.RankParm DESC";

try
{
pPLC->Open(CRecordset::snapshot, szPLCString, CRecordset::readOnly);
}

catch(CDBException* e)
{
CString szFunction("pPLC->Open");
CString szStock("All");;
HandleError(e, szFunction, szStock);
}
Thanks, Pavel.
 
hi,
I don't see some continuation symbol ('\') in
some lines, but probably are out of video.

To avoid "compilation" mis-understandings and center
the problem in the query syntax use the following tecn.:

CString
szPLCString = "SELECT TOP 60 C.Stock " ;
szPLCString += "FROM [SELECT B.* FROM Policies " ;
szPLCString += "AS B ORDER BY B.Stock, ..." ;
.....
szPLCString += "ORDER BY B.RankParm DESC" ;

try
{
pPLC->Open(CRecordset::snapshot, szPLCString, ...

However print or display in debug the string of the query.

Another way is to "complicate" the query, step by step,
to find where and when the problem occours, and not implement in one shot a query that comes from another environment.

bye
 
Thanks for advice. I'm sure that the query is fine for compilation since I did not have any compile errors. All back slashes are OK. The problem is that video does not have long enough line. I was able to resolve the problem by replacing "SELECT TOP 60 C.Stock" with "SELECT TOP 60 C.*". I can not understand why it matters. It seems that when I select all columns the column sequence problem disappears. It works fine for now.
Thanks again, Pavel.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top