problem with adding and deleting ADO,also needs resources
-
hi; i new in MFC and i have a problem with adding and deleting but basically i can attribute my problem to lack of proper tutorials on the same. ANy site i try to get tutorials i end up with getting complex stuff posted by Gurus tryiong to implement not the usual basic works that am in need of so i have been tring to understand the whole concept by following one simple code example i have and so in that connection if you know a site i can get real introduction tutorials to ADO in MFC i will appreciate but in the mean time help me get thru this problem at hand(my name is king'ori from kenya); I want to add supplierid (not null primary key) and suppliername(not null) to the SUPPLIERS table (which i have alreaady created); so i have included the adofields.h in my project..,done the ::initialization, the opening() plus i have these functions void MyView:: RefreshSupplier() { if(p_rsSupplier->BOFILE || p_rsSupplierEOFILE) return; m_strSupplierName =(const char*)_bstr_t(FieldValue(p_rsSupplier,"suppliername"); m_lSupplierID = long(FieldValue(p_rsSupplier,"supplierID")); UpdateData(FALSE); } vooid MyView:: UpdateSupplier() { if(p_rsSupplier->BOFILE || p_rsSupplier->EOFILE) retirn; CString strSupplier; long lsupplier; UpgateData(); if(lSupplier != m_lSupplierID) FieldValue(p_rsSupplier,"supplierid",m_lSupplierID); if(strSupplier != m_strSupplierName) FieldValue(p_rsSupplier,"suppliername",m_strSuppliername); } void MyView::BlankSupplier() { m_lSupplierID = 0; m_strSupplierName = _T(" "); } problem comes i dont understand the adding flow,- for instance why do you have to blank the recordset? what comes first p_rsSupplier->Addnew() or is it UpdateSupplier() and why; this is not working void MyView::AddSupplier() { BlankSupplier(); //why this and my fields are not null? p_rsSupplier->AddNew(); UpdateData(); p_rsSupplier->PutCollect(_variant_t("Suppliername",_variant((LPCTSTR)m_strName); p_rsSupplier->PutCollect....suppierID); p_rsSupplier->MoveNext(); RefreshSupplier(); } void MyView::DeleteSupplier() { if(p_rsSupplier->BOFILE || p_rsSupplier->EOFILE) { if(Warning MSgBx ==YES) { p_rsSupplier->Delete(adAffectCurrent); p_rsSupplier->MovePrevious(); RefreshSupplier(); }