Friday, December 4, 2009

Database Connection Using DAO in VC++

File Name :: DAOConnView.cpp

Coding ::

void CDAOConnView::OnMoveFirst()

{

// TODO: Add your control notification handler code here

UpdateData();

m_pSet->MoveFirst();

UpdateData(FALSE);

}

void CDAOConnView::OnMovePrev()

{

// TODO: Add your control notification handler code here

UpdateData();

m_pSet->MovePrev();

if(m_pSet->IsBOF() == TRUE)

{

MessageBox("First Record","Alert");

m_pSet->MoveFirst();

}

UpdateData(FALSE);

}

void CDAOConnView::OnMoveNext()

{

// TODO: Add your control notification handler code here

UpdateData();

m_pSet->MoveNext();

if(m_pSet->IsEOF() == TRUE)

{

MessageBox("Last Record","Alert" );

m_pSet->MoveLast();

}

UpdateData(FALSE);

}

void CDAOConnView::OnMoveLast()

{

// TODO: Add your control notification handler code here

UpdateData();

m_pSet->MoveLast();

UpdateData(FALSE);

}

void CDAOConnView::OnAdd()

{

// TODO: Add your control notification handler code here

UpdateData();

m_pSet->AddNew();

UpdateData(FALSE);

}

void CDAOConnView::OnSave()

{

// TODO: Add your control notification handler code here

UpdateData();

m_pSet->Update();

UpdateData(FALSE);

}

void CDAOConnView::OnUpdate()

{

// TODO: Add your control notification handler code here

m_pSet->Edit();

}

void CDAOConnView::OnDelete()

{

// TODO: Add your control notification handler code here

UpdateData();

m_pSet->Delete();

m_pSet->Requery();

m_pSet->MoveNext();

UpdateData(FALSE);

}

OLEDB CONNECTION IN VC++

COledb_connectView.h
public:
COledb_connectDoc* GetDocument();
bool flag;



COledb_connectView.cpp
void COledb_connectView::OnInitialUpdate()
{
m_pSet = &GetDocument()->m_oledb_connectSet;
{
CWaitCursor wait;
HRESULT hr = m_pSet->Open();
if (hr != S_OK)
{
AfxMessageBox(_T("Record set failed to open."), MB_OK);
// Disable the Next and Previous record commands,
// since attempting to change the current record without an
// open RecordSet will cause a crash.
m_bOnFirstRecord = TRUE;
m_bOnLastRecord = TRUE;
}
}
m_rollno=m_pSet->m_rollno;
m_marks=m_pSet->m_marks;
COleDBRecordView::OnInitialUpdate();

}
void COledb_connectView::Onfirst()
{
// TODO: Add your control notification handler code here
UpdateData();
m_pSet->MoveFirst();
m_rollno=m_pSet->m_rollno;
m_marks=m_pSet->m_marks;

UpdateData(false);
}

void COledb_connectView::Onlast()
{
// TODO: Add your control notification handler code here
UpdateData();
m_pSet->MoveLast();
m_rollno=m_pSet->m_rollno;
m_marks=m_pSet->m_marks;
UpdateData(false);

}

void COledb_connectView::Oninsert()
{
// TODO: Add your control notification handler code here
UpdateData();
m_rollno=0;
m_marks=0;
UpdateData(false);
}

void COledb_connectView::Onsave()
{
// TODO: Add your control notification handler code here
UpdateData();
m_pSet->m_rollno=m_rollno;
m_pSet->m_marks=m_marks;
if(flag==true)//if flag is true then update operation will perform
{

m_pSet->SetData();
}
else //if flag is true then INSERT operation will perform
{
m_pSet->Insert();
}
flag=false;

UpdateData(false);
}

void COledb_connectView::Onnext()
{
// TODO: Add your control notification handler code here
UpdateData();
m_pSet->MoveNext();
m_rollno=m_pSet->m_rollno;
m_marks=m_pSet->m_marks;

UpdateData(false);
}

void COledb_connectView::Onprevious()
{
// TODO: Add your control notification handler code here
UpdateData();
m_pSet->MovePrev();
m_rollno=m_pSet->m_rollno;
m_marks=m_pSet->m_marks;

UpdateData(false);
}

void COledb_connectView::Onupdate()
{
// TODO: Add your control notification handler code here
UpdateData();
m_pSet->m_rollno=m_rollno;
m_pSet->m_marks=m_marks;
m_pSet->Update();
flag=true;
UpdateData(false);
}

void COledb_connectView::Ondelete()
{
// TODO: Add your control notification handler code here
UpdateData();
m_pSet->Delete();
m_pSet->MoveFirst();

m_rollno=m_pSet->m_rollno;
m_marks=m_pSet->m_marks;
UpdateData(false);

}

Thursday, December 3, 2009

Practical Assignment

M.Sc (IT & CA) Sem – I
Object Oriented Programming using Visual C++
Practical List - II


(1)
Develop GDI application Using Menu and Toolbar to Change Shape and Color.


(2)
Write application for the GDI that use the ColorDialog and FontDialog.



(3)
 Write application for the GDI that use the Bitmap,Icon and Cursor.


(4) 
Write dialog based application that Write and Read data using the Seek() function.  


(5)
Write application that show the FileStatus with Exception Handling.


(6)
Write application that implement Serialization 



(7)
Develop a simple MDI application.



(8)
Develop simple Web Browser using CHtmlView



(9)
Develop application which can perform Insert, Update, Delete, Search using ODBC.



(10)
Develop application which can perform Insert, Update, Delete, Search using DAO.



(11)
Develop application which can perform Insert, Update, Delete, Search using OLEDB.


(12) 
 Develop Simple Active-X program.


Submission Date 

For Theory and Practical Assignment
On or Before 
26 - 12 - 2009 , Saturday