ODBC Connectivity
ODBC Connectivity
1. Create a Table using MS-Access or any other tool preferable for you.
2. Configure an ODBC data source to point to the database just created by running
the ODBC Administrator, present in the Control Panel on your computer as
follows.
a. Control panel Administrative Tools Data Sources (ODBC) Add
Select an appropriate driver Finish Give a suitable data source
name and description Click Select Select and point the database to
the database you just created finish the task by giving Ok and exit the
control panel
3. Go to your *****Set.cpp in your solution explorer and comment out the #error
Security Issue line.
5. In the dialog frame displayed, place the required controls (static and edit controls
etc.,) using the tool bar and save the form. Have buttons for adding, deleting,
updating records.
8. In the above e.g., m_szColumn1 is the variable which holds a particular field of
the database. This can be obtained from <your project name>Set.h file in the
solution explorer
9. Save the project after adding the required no of DDX lines (depending on the no
of controls you have on the form).
Create PDF files without this message by purchasing novaPDF printer (http://www.novapdf.com)
10. Double click the button for adding records this takes you to the message
handler
void CstudentodbcView::OnBnClickedButton2()
{
// TODO: Add your control notification handler code here
if(m_pSet->CanAppend())
{
m_pSet->AddNew();
UpdateData(TRUE);
m_pSet->Update();
m_pSet->Requery();
m_pSet->MoveLast();
}
else
AfxMessageBox(_T("Not possible"));
}
For Deletion:
void CstudentodbcView::OnBnClickedButton1()
{
// TODO: Add your control notification handler code here
m_pSet->Delete();
m_pSet->MovePrev();
m_pSet->Requery();
UpdateData(FALSE);
}
For Editing:
void CstudentodbcView::OnBnClickedButton3()
{
// TODO: Add your control notification handler code here
m_pSet->Edit();
m_pSet->Update();
UpdateData(TRUE);
m_pSet->Update();
m_pSet->Requery();
}
********
Create PDF files without this message by purchasing novaPDF printer (http://www.novapdf.com)