Is this a MFC/DAO bug???
Di Luo -- photosoft@monmouth.com
Tuesday, December 03, 1996
Environment: VC++ 4.2b, Win 95
Is this a MFC/DAO bug???
I use MFC Application Wizard to create a project with the "Database with file
support" option, and then just add the following code into the view's OnDraw():
CString strSQL;
strSQL.Format("SELECT DISTINCT Contacts.LastName FROM Contacts");
CDaoQueryDef qd(m_pSet->m_pDatabase);
qd.Create(NULL, (LPCTSTR)strSQL);
try
{
if(m_pSet->IsOpen())
m_pSet->Close();
m_pSet->Open(&qd);
}
catch(CDaoException *e)
{
......
}
What I am trying to do is to execute a simple SQL to retrieve distinct last name
from the table Contacts by using "SELECT DISTINCT Contacts.LastName FROM Contacts"
(Contacts is MS ACCESS sample table). it fails with following message:
"GetRows failed. The requested column is not a member of this recordset".
I have tried using both table or Dynaset RecordSet type.
However if I use "SELECT * FROM Contacts", It works fine.
I also tested the SQL from Access directly with no problem.
It seems to me it is MFC/DAO bug. Does anybody have similar experience?
Thanks
Di Luo
Mike Blaszczak -- mikeblas@nwlink.com
Thursday, December 05, 1996
[Mini-digest: 9 responses]
At 12:22 12/3/96 -0800, Di Luo wrote:
>Environment: VC++ 4.2b, Win 95
>Is this a MFC/DAO bug???
I don't think it is, but you've not provided enough information to decide
either way.
>(Contacts is MS ACCESS sample table). it fails with following message:
> "GetRows failed. The requested column is not a member of this recordset".
You need to show what list of columns are in the DoFieldExchange() function
of your recordset. It seems to me that you're naming lots of fields in
there, even though you're only selecting one field with your smaller
SELECT statement.
.B ekiM
http://www.nwlink.com/~mikeblas/
I'm afraid I've become some sort of speed freak.
These words are my own. I do not speak on behalf of Microsoft.
-----From: Paul Armstrong
try "SELECT DISTINCT LastName FROM Contacts" as your query.
----------
From: Di Luo[SMTP:photosoft@monmouth.com]
Sent: Tuesday, December 03, 1996 3:22 PM
To: mfc-l@netcom.com
Subject: Is this a MFC/DAO bug???
Environment: VC++ 4.2b, Win 95
Is this a MFC/DAO bug???
I use MFC Application Wizard to create a project with the "Database with file
support" option, and then just add the following code into the view's OnDraw():
CString strSQL;
strSQL.Format("SELECT DISTINCT Contacts.LastName FROM Contacts");
CDaoQueryDef qd(m_pSet->m_pDatabase);
qd.Create(NULL, (LPCTSTR)strSQL);
try
{
if(m_pSet->IsOpen())
m_pSet->Close();
m_pSet->Open(&qd);
}
catch(CDaoException *e)
{
......
}
What I am trying to do is to execute a simple SQL to retrieve distinct last name
from the table Contacts by using "SELECT DISTINCT Contacts.LastName FROM Contacts"
(Contacts is MS ACCESS sample table). it fails with following message:
"GetRows failed. The requested column is not a member of this recordset".
I have tried using both table or Dynaset RecordSet type.
However if I use "SELECT * FROM Contacts", It works fine.
I also tested the SQL from Access directly with no problem.
It seems to me it is MFC/DAO bug. Does anybody have similar experience?
Thanks
Di Luo
-----From: Tom Allen
I doubt if it is an MFC or DAO bug. What happens if you remove the =
table qualifier from the column name and/or wrap brackets [ ] around the =
column name? e.g.:
"SELECT DISTINCT LastName from Contacts"
or
"SELECT DISTINCT [LastName] from Contacts"
-TA
----------
From: Di Luo[SMTP:photosoft@monmouth.com]
Sent: Tuesday, December 03, 1996 3:22 PM
To: mfc-l@netcom.com
Subject: Is this a MFC/DAO bug???
Environment: VC++ 4.2b, Win 95
Is this a MFC/DAO bug???
I use MFC Application Wizard to create a project with the "Database with =
file=20
support" option, and then just add the following code into the view's =
OnDraw():
CString strSQL;
strSQL.Format("SELECT DISTINCT Contacts.LastName FROM Contacts");=20
CDaoQueryDef qd(m_pSet->m_pDatabase);
qd.Create(NULL, (LPCTSTR)strSQL);
try
{
if(m_pSet->IsOpen())
m_pSet->Close();
=09
m_pSet->Open(&qd);
}
catch(CDaoException *e)
{
......
}
=20
What I am trying to do is to execute a simple SQL to retrieve =
distinct last name =20
from the table Contacts by using "SELECT DISTINCT Contacts.LastName FROM =
Contacts"=20
(Contacts is MS ACCESS sample table). it fails with following message:
"GetRows failed. The requested column is not a member of this =
recordset".
I have tried using both table or Dynaset RecordSet type.=20
However if I use "SELECT * FROM Contacts", It works fine.=20
I also tested the SQL from Access directly with no problem.
It seems to me it is MFC/DAO bug. Does anybody have similar experience? =
Thanks
Di Luo
-----From: George Grant
I think I know your problem, I ran across something like it a while =
back. Your query:
SELECT DISTINCT Contacts.LastName FROM Contacts
should be:
SELECT DISTINCT LastName FROM Contacts
The problem is that JET only prefixes the table name when there is a =
naming conflict between two or more columns as the result of a join, =
etc.
Hope that helps...
-George
----------
From: Di Luo[SMTP:photosoft@monmouth.com]
Sent: Tuesday, December 03, 1996 12:22 PM
To: mfc-l@netcom.com
Subject: Is this a MFC/DAO bug???
Environment: VC++ 4.2b, Win 95
Is this a MFC/DAO bug???
I use MFC Application Wizard to create a project with the "Database with =
file=20
support" option, and then just add the following code into the view's =
OnDraw():
CString strSQL;
strSQL.Format("SELECT DISTINCT Contacts.LastName FROM Contacts");=20
CDaoQueryDef qd(m_pSet->m_pDatabase);
qd.Create(NULL, (LPCTSTR)strSQL);
try
{
if(m_pSet->IsOpen())
m_pSet->Close();
=09
m_pSet->Open(&qd);
}
catch(CDaoException *e)
{
......
}
=20
What I am trying to do is to execute a simple SQL to retrieve =
distinct last name =20
from the table Contacts by using "SELECT DISTINCT Contacts.LastName FROM =
Contacts"=20
(Contacts is MS ACCESS sample table). it fails with following message:
"GetRows failed. The requested column is not a member of this =
recordset".
I have tried using both table or Dynaset RecordSet type.=20
However if I use "SELECT * FROM Contacts", It works fine.=20
I also tested the SQL from Access directly with no problem.
It seems to me it is MFC/DAO bug. Does anybody have similar experience? =
Thanks
Di Luo
-----From: tcatchick@aesprodata.com.au
hi Di Luo
If Contacts is the table name and LastName a field in this table then
as your SQL string statement try just using LastName without using the
alias
Regards
Theron. C.
______________________________ Reply Separator _________________________________
Subject: Is this a MFC/DAO bug???
Author: mfc-l@netcom.com at INTERNET
Date: 06/12/96 15:16
Environment: VC++ 4.2b, Win 95
Is this a MFC/DAO bug???
I use MFC Application Wizard to create a project with the "Database with file
support" option, and then just add the following code into the view's OnDraw():
CString strSQL;
strSQL.Format("SELECT DISTINCT Contacts.LastName FROM Contacts");
CDaoQueryDef qd(m_pSet->m_pDatabase);
qd.Create(NULL, (LPCTSTR)strSQL);
try
{
if(m_pSet->IsOpen())
m_pSet->Close();
m_pSet->Open(&qd);
}
catch(CDaoException *e)
{
......
}
What I am trying to do is to execute a simple SQL to retrieve distinct last
na me
from the table Contacts by using "SELECT DISTINCT Contacts.LastName FROM
Contacts "
(Contacts is MS ACCESS sample table). it fails with following message:
"GetRows failed. The requested column is not a member of this recordset".
I have tried using both table or Dynaset RecordSet type.
However if I use "SELECT * FROM Contacts", It works fine.
I also tested the SQL from Access directly with no problem.
It seems to me it is MFC/DAO bug. Does anybody have similar experience?
Thanks
Di Luo
-----From: "P. Senthil"
Di Luo wrote:
>
> Postage paid by: [Image]
>
> ---------------------------------------------------------------
>
> Environment: VC++ 4.2b, Win 95
>
> Is this a MFC/DAO bug???
>
> I use MFC Application Wizard to create a project with the "Database with file
> support" option, and then just add the following code into the view's OnDraw():
>
> CString strSQL;
> strSQL.Format("SELECT DISTINCT Contacts.LastName FROM Contacts");
> CDaoQueryDef qd(m_pSet->m_pDatabase);
> qd.Create(NULL, (LPCTSTR)strSQL);
> try
> {
> if(m_pSet->IsOpen())
> m_pSet->Close();
>
> m_pSet->Open(&qd);
> }
> catch(CDaoException *e)
> {
> ......
> }
>
> What I am trying to do is to execute a simple SQL to retrieve distinct last name
> from the table Contacts by using "SELECT DISTINCT Contacts.LastName FROM Contacts"
> (Contacts is MS ACCESS sample table). it fails with following message:
> "GetRows failed. The requested column is not a member of this recordset".
> I have tried using both table or Dynaset RecordSet type.
>
> However if I use "SELECT * FROM Contacts", It works fine.
> I also tested the SQL from Access directly with no problem.
>
> It seems to me it is MFC/DAO bug. Does anybody have similar experience?
>
> Thanks
>
> Di Luo
This usually happens if the number of columns in the SQL Query does not
match the columns specified in the dynaset or recordset. Unfortunately,
a single recordset or dynaset cannot be used for retrieving only a
subset of the selected columns, you have to use a different recordset
for that.
P. Senthil
---------------------------------------------------
Mail: senthilp@geocities.com
WWW: www.geocities.com/SiliconValley/Heights/6504/
---------------------------------------------------
-----From: Rogas
Di Luo wrote:
>
> Environment: VC++ 4.2b, Win 95
>
> Is this a MFC/DAO bug???
>
> I use MFC Application Wizard to create a project with the "Database with file
> support" option, and then just add the following code into the view's OnDraw():
>
> CString strSQL;
> strSQL.Format("SELECT DISTINCT Contacts.LastName FROM Contacts");
> CDaoQueryDef qd(m_pSet->m_pDatabase);
> qd.Create(NULL, (LPCTSTR)strSQL);
> try
> {
> if(m_pSet->IsOpen())
> m_pSet->Close();
>
> m_pSet->Open(&qd);
> }
> catch(CDaoException *e)
> {
> ......
> }
>
> What I am trying to do is to execute a simple SQL to retrieve distinct last name
> from the table Contacts by using "SELECT DISTINCT Contacts.LastName FROM Contacts"
> (Contacts is MS ACCESS sample table). it fails with following message:
> "GetRows failed. The requested column is not a member of this recordset".
> I have tried using both table or Dynaset RecordSet type.
>
> However if I use "SELECT * FROM Contacts", It works fine.
> I also tested the SQL from Access directly with no problem.
>
> It seems to me it is MFC/DAO bug. Does anybody have similar experience?
>
> Thanks
>
> Di Luo
Hi
I am developing an application that uses DAO and I had such problems.
You must check very carefully if you have all column names typed
correctly. Besides I would try
"SELECT DISTINCT LastName FROM Contacts" instead of your
"Contacts.LastName".
Then it should work.
Here are some queries of my program:
"SELECT F.IDfond, F.nom, \
fut_larg, fut_haut, fut_dispY, semelle_larg, semelle_haut \
FROM fondation AS F \
WHERE F.public<>0 \
AND F.nom=\""+ szName +"\";"
"SELECT A.IDass, A.nom \
FROM assemblage AS A \
WHERE A.public<>0 \
AND nom=\""+ szName +"\";"
"SELECT A.IDass, A.nom, A.type, R2.IDmontant1, \
R2.IDmontant2, R2.nr_queue, R2.position \
FROM structure AS S, assemblage AS A, Rstruct_ass AS R2 \
WHERE A.IDass=R2.IDass \
AND S.IDstruct=R2.IDstruct \
AND S.IDstruct=" + CString(idstr) + " \
ORDER BY R2.nr_queue;"
szName and idstr are parameters to query I pass.
Hope you find it useful
Rogas
-----From: Mast-CBT
At 12.22 03/12/96 -0800, you wrote:
>Environment: VC++ 4.2b, Win 95
>
>Is this a MFC/DAO bug???
>
>I use MFC Application Wizard to create a project with the "Database with file
>support" option, and then just add the following code into the view's OnDraw():
>
> CString strSQL;
> strSQL.Format("SELECT DISTINCT Contacts.LastName FROM Contacts");
> CDaoQueryDef qd(m_pSet->m_pDatabase);
> qd.Create(NULL, (LPCTSTR)strSQL);
> try
> {
> if(m_pSet->IsOpen())
> m_pSet->Close();
>
> m_pSet->Open(&qd);
> }
> catch(CDaoException *e)
> {
> ......
> }
>
>What I am trying to do is to execute a simple SQL to retrieve distinct
last name
>from the table Contacts by using "SELECT DISTINCT Contacts.LastName FROM
Contacts"
>(Contacts is MS ACCESS sample table). it fails with following message:
> "GetRows failed. The requested column is not a member of this recordset".
>I have tried using both table or Dynaset RecordSet type.
>
>However if I use "SELECT * FROM Contacts", It works fine.
>I also tested the SQL from Access directly with no problem.
>
>It seems to me it is MFC/DAO bug. Does anybody have similar experience?
>
>
>Thanks
>
>Di Luo
>
>
For this problem you can see article ID:Q139994 about:
'Specifying Table Name with Column Name in MFC DAO'.
Search in Microsoft site 'www.microsoft.com', Microsoft Support, Knowledge Base.
I hope this help you.
Bye
Fabio
--------------------------------------------------
Fabio Saponaro
Context Systems Group - Italian Branch
Magenta (MI)
Tel. ++ 39 2 97298145
Fax ++ 39 2 97298225
http://www.web.csg.it
--------------------------------------------------
-----From: "Michael Potter"
I think you are missing a call to
qd.Append().
Or you can skip the qd all together and pass the strSQL to the
m_pSet->Open() method.
Mike
----------
> From: Di Luo
> To: mfc-l@netcom.com
> Subject: Is this a MFC/DAO bug???
> Date: Tuesday, December 03, 1996 2:22 PM
>
> Environment: VC++ 4.2b, Win 95
>
> Is this a MFC/DAO bug???
>
> I use MFC Application Wizard to create a project with the "Database with
file
> support" option, and then just add the following code into the view's
OnDraw():
>
> CString strSQL;
> strSQL.Format("SELECT DISTINCT Contacts.LastName FROM Contacts");
> CDaoQueryDef qd(m_pSet->m_pDatabase);
> qd.Create(NULL, (LPCTSTR)strSQL);
> try
> {
> if(m_pSet->IsOpen())
> m_pSet->Close();
>
> m_pSet->Open(&qd);
> }
> catch(CDaoException *e)
> {
> ......
> }
>
> What I am trying to do is to execute a simple SQL to retrieve distinct
last name
> from the table Contacts by using "SELECT DISTINCT Contacts.LastName FROM
Contacts"
> (Contacts is MS ACCESS sample table). it fails with following message:
> "GetRows failed. The requested column is not a member of this
recordset".
> I have tried using both table or Dynaset RecordSet type.
>
> However if I use "SELECT * FROM Contacts", It works fine.
> I also tested the SQL from Access directly with no problem.
>
> It seems to me it is MFC/DAO bug. Does anybody have similar experience?
>
>
> Thanks
>
> Di Luo
| Вернуться в корень Архива
|