friends

i create mfc application and create two table -same database,same content.
ex:table content(table 1,table 1)
employee id,employee name,department,salary,mobile no.

now i view data from table 1 and that data to insert on table 2. i doing many way,but i didnt done.please any one can help me?

this operation only do in VISUAL C++ 6.0 AND DATABASE MS-ACCESS OR ORACLE.

thanking you for helping

You should create at least 3 CRecordsets -- one for table1, one for table2 and one for the joined table1+table2 (based on primary and foreign keys).

That way, you can use (insert, update, delete, select) for each table individually or you can just read the combined/joined table.

You should create at least 3 CRecordsets -- one for table1, one for table2 and one for the joined table1+table2 (based on primary and foreign keys).

That way, you can use (insert, update, delete, select) for each table individually or you can just read the combined/joined table.

can you tell me how to join two table on mfc application...

thank you for reply

Use the class wizard to create an Odbc Recordset class.
Use the SQL inside of the class to reference both tables.

In the GetDefaultSQL() function, put the names of both the tables if you did not select them in the wizard.

CString CLmSubProfileByEsn::GetDefaultSQL()
{
	return _T("[MAPS].[NAMES], [MAPS].[ADDRESS]"); // ** <<< TWO TABLES
}

put the WHERE clause in the m_strFilter in the constructor:

m_strFilter	 =_T("NAMES.ADDRESS_ID=ADDRESS.ADDRESS_ID AND NAME=?");

...and the columns go in the DoFieldExchange including any SQL parameters.

void CClassName::DoFieldExchange(CFieldExchange* pFX)
{
	//{{AFX_FIELD_MAP(CLmSubProfileByEsn)
	pFX->SetFieldType(CFieldExchange::outputColumn);
	RFX_Text(pFX, _T("[NAME]"), m_NAME);
	RFX_Text(pFX, _T("[ADDRESS]"), m_ADDRESS);
	//}}AFX_FIELD_MAP
	pFX->SetFieldType(CFieldExchange::param);
	RFX_Text(pFX, _T("NAME"), m_NAME);
}

Use the class wizard to create an Odbc Recordset class.
Use the SQL inside of the class to reference both tables.

In the GetDefaultSQL() function, put the names of both the tables if you did not select them in the wizard.

CString CLmSubProfileByEsn::GetDefaultSQL()
{
	return _T("[MAPS].[NAMES], [MAPS].[ADDRESS]"); // ** <<< TWO TABLES
}

put the WHERE clause in the m_strFilter in the constructor:

m_strFilter	 =_T("NAMES.ADDRESS_ID=ADDRESS.ADDRESS_ID AND NAME=?");

...and the columns go in the DoFieldExchange including any SQL parameters.

void CClassName::DoFieldExchange(CFieldExchange* pFX)
{
	//{{AFX_FIELD_MAP(CLmSubProfileByEsn)
	pFX->SetFieldType(CFieldExchange::outputColumn);
	RFX_Text(pFX, _T("[NAME]"), m_NAME);
	RFX_Text(pFX, _T("[ADDRESS]"), m_ADDRESS);
	//}}AFX_FIELD_MAP
	pFX->SetFieldType(CFieldExchange::param);
	RFX_Text(pFX, _T("NAME"), m_NAME);
}

same method i will use oracle database??? its possible???


lot of thanks for helping

Yes, but remember to register your database in the ODBC Administrator.

[somewhere like]:
Control Panel->Administrative Tools->DataSources (ODBC) / System DSN

Edited 5 Years Ago by thines01: n/a

This article has been dead for over six months. Start a new discussion instead.