Please Help:
I need to connect access database through code in VC++ .6 and i've to read data from edit text and compare this value to the primary key of my database. if those are matched then i need to get all data from the database and i need to delete the record from the primary key..

In simple terms, you will need to:
1) Create an ODBC entry (in ODBC Administrator) for the specific Access Database
2) Create an MFC recordset to bind a class to the query (to the table or tables)
3) Use that recordset in your regular code to retrieve the data.

Here is the MSDN article for it.
http://msdn.microsoft.com/en-us/library/08x38eza(v=VS.71).aspx

The good thing about VC6 is that you can use the Class Wizard to create the CRecordset and connect it to the ODBC entry (control W).

If you modify the wizard-generated code, YOU OWN IT.
It's OK to do so, but the wizard will no longer handle the code once it has been manipulated inside of the special //{{ markers.


Very important elements:

Tables are referenced in the GetDefaultSQL() method
Fields are manipulated in the DoFieldExchange() method
The WHERE clause is handled in m_strFilter string (without using the word WHERE)

Parameters are handled through position specific question-marks in the m_strFilter
...and filled in the DoFieldExchange() OUTSIDE of the //}}AFX_FIELD_MAP
with something that will look like:

pFX->SetFieldType(CFieldExchange::param);
RFX_Text(pFX, _T("[RPT_REPORT_ID]"), m_strREPORTID);

You can override the query by modifying what is returned in the GetDefaultSQL(), but
the results are carried back through the DoFieldExchange().

It took me quite a while to get comfortable with this.

Here is a complete tutorial on how to access database from MFC programs.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.