Using CRecordSet for ODBC joins 
Author Message
 Using CRecordSet for ODBC joins

I need to perform a join between two tables in a database. I have read the
Microsoft document describing the steps to do this ("Recordset: Performing
a Join (ODBC)").

The document states that I should rewrite the GetDefaultSQL member function
(among other things) to return a string containing a comma-delimited list
of table names. I have done this. After following the steps listed in the
document, running the program produces a SQL error that says:

"The Microsoft Jet database engine cannot find the input table or query
'tblEmployee, tblDepartmentName'. Make sure it exists and that the name is
spelled correctly"

Needless to say, the tables do exist and they are spelled correctly. I can
read data from the tables individually from other recordsets in my program.
BTW, I am using ODBC 3.5 and VC++ 5.0.

Has anyone had any experience working with joins and CRecordSets? Is there
something missing from the document? Any Ideas on what I might be doing
wrong?

Any ideas would be greatly appreciated.

Doug



Tue, 12 Sep 2000 03:00:00 GMT  
 Using CRecordSet for ODBC joins

Don't forget brackets, try this '[tblEmployee], [tblDepartmentName]'

Regards, Michael

Quote:
>I need to perform a join between two tables in a database. I have read the
>Microsoft document describing the steps to do this ("Recordset: Performing
>a Join (ODBC)").

>The document states that I should rewrite the GetDefaultSQL member function
>(among other things) to return a string containing a comma-delimited list
>of table names. I have done this. After following the steps listed in the
>document, running the program produces a SQL error that says:

>"The Microsoft Jet database engine cannot find the input table or query
>'tblEmployee, tblDepartmentName'. Make sure it exists and that the name is
>spelled correctly"

>Needless to say, the tables do exist and they are spelled correctly. I can
>read data from the tables individually from other recordsets in my program.
>BTW, I am using ODBC 3.5 and VC++ 5.0.

>Has anyone had any experience working with joins and CRecordSets? Is there
>something missing from the document? Any Ideas on what I might be doing
>wrong?

>Any ideas would be greatly appreciated.

>Doug



Wed, 13 Sep 2000 03:00:00 GMT  
 Using CRecordSet for ODBC joins

Use the join-escape sequence ( the description is avaliabe in SQL-manual )
and
return a complete SQL-join-statement, like

"SELECT EmpID, EmpName, DepartpentName  FROM
{oj Emloyee LEFT OUTER JOIN Department ON Employee.DepID =
Department.DepID }"

 from GetDefaultSQL() function.

Douglas A. Sevy schrieb in Nachricht

Quote:
>I need to perform a join between two tables in a database. I have read the
>Microsoft document describing the steps to do this ("Recordset: Performing
>a Join (ODBC)").

...


Wed, 13 Sep 2000 03:00:00 GMT  
 Using CRecordSet for ODBC joins

I'm able to work without putting any brackets. I think brackets are
required only if there are any blank spaces in the table name, otherwise
they are not must.

Arun

Quote:

> Don't forget brackets, try this '[tblEmployee], [tblDepartmentName]'

> Regards, Michael

> >I need to perform a join between two tables in a database. I have read the
> >Microsoft document describing the steps to do this ("Recordset: Performing
> >a Join (ODBC)").

> >The document states that I should rewrite the GetDefaultSQL member function
> >(among other things) to return a string containing a comma-delimited list
> >of table names. I have done this. After following the steps listed in the
> >document, running the program produces a SQL error that says:

> >"The Microsoft Jet database engine cannot find the input table or query
> >'tblEmployee, tblDepartmentName'. Make sure it exists and that the name is
> >spelled correctly"

> >Needless to say, the tables do exist and they are spelled correctly. I can
> >read data from the tables individually from other recordsets in my program.
> >BTW, I am using ODBC 3.5 and VC++ 5.0.

> >Has anyone had any experience working with joins and CRecordSets? Is there
> >something missing from the document? Any Ideas on what I might be doing
> >wrong?

> >Any ideas would be greatly appreciated.

> >Doug

--


Fri, 15 Sep 2000 03:00:00 GMT  
 Using CRecordSet for ODBC joins

Thanks Michael,

This is what I found I was doing wrong (with brackets!):

CString CMyClass::GetDefaultSQL ()
{
   return (_T ("[tblEmployee, tblDepartmentName]");   // WRONG
   return (_T ("[tblEmployee], [tblDepartmentName]"); // this is OK

Quote:
}

The second problem:

void CMyClass :: DoFieldExchange (......)
{
   RFX_Text (pFX, "[tblEmployee.DepartmentNum]", m_DepartmentNum);// WRONG
   RFX_Text (pFX, "tblEmployee.[DepartmentNum]", m_DepartmentNum);// OK

Quote:
}

With these two corrections, everything works fine. As was pointed out, you
can also remove the brackets and it will work fine, but only because there
are no spaces in the table or field names that I am using.

Thanks again
Doug



Quote:
> Don't forget brackets, try this '[tblEmployee], [tblDepartmentName]'

> Regards, Michael

> >I need to perform a join between two tables in a database. I have read
the
> >Microsoft document describing the steps to do this ("Recordset:
Performing
> >a Join (ODBC)").

> >The document states that I should rewrite the GetDefaultSQL member
function
> >(among other things) to return a string containing a comma-delimited
list
> >of table names. I have done this. After following the steps listed in
the
> >document, running the program produces a SQL error that says:

> >"The Microsoft Jet database engine cannot find the input table or query
> >'tblEmployee, tblDepartmentName'. Make sure it exists and that the name
is
> >spelled correctly"

> >Needless to say, the tables do exist and they are spelled correctly. I
can
> >read data from the tables individually from other recordsets in my
program.
> >BTW, I am using ODBC 3.5 and VC++ 5.0.

> >Has anyone had any experience working with joins and CRecordSets? Is
there
> >something missing from the document? Any Ideas on what I might be doing
> >wrong?

> >Any ideas would be greatly appreciated.

> >Doug



Fri, 15 Sep 2000 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. CRecordset (ODBC) + Join = ReadOnly?

2. Join using CRecordset

3. Regarding simple database modifications using CRecordset (MFC) and ODBC

4. Problem with ODBC update using CRecordset

5. Need ID of a record added to SQL-Server using MFC/ODBC/CRecordset

6. Regarding simple database modifications using CRecordset (MFC) and ODBC

7. About performance of using ODBC with CRecordset to connect database?Thank you

8. ODBC Access using CRecordSet

9. CRecordset - Join statments and dbSnapshots???

10. CRecordset and joining tables

11. CRecordset updateable join with SQL Server 7.0

12. CRecordset join query issues

 

 
Powered by phpBB® Forum Software