Link to home
Start Free TrialLog in
Avatar of mathieu_cupryk
mathieu_cuprykFlag for Canada

asked on

Accessing an csv file instead of an mdb file.

How can I set this up to access an accces file:

void CPCMView::FillResults()      // From Old RAM...
{

      CWaitCursor wait;  
      
      CString sStr;
      // LV_ITEM lvitem;
      // Int iActualItem;
    // The following code demonstrates how to extract the BSTR value from a COleVariant into a CString
      COleVariant varName(_T(""), VT_BSTRT);
      
      CString strText;
      
      CString sTemp, sTemp2, sTemp3;
      
      sTemp = sTemp2 = sTemp3 = "";
      
      int iLength=0;

    int iNumRecords = m_pSet->GetRecordCount();

      m_pSet->MoveFirst();
      //m_pGrid->SetRowCount(iNumRecords+2); // PLMK +2

      //int i = 1;
      GV_ITEM Item;
    // Populate datagrid
      ///////////////////////////////////////////////////////////////////////////////////////
      while(!m_pSet->IsEOF())
      {
            if (m_iLastPurposeID != m_pSet->m_purposeID)
            {
                  if (m_pSet->m_OrgName != "")
                  {
                        //i++; //ESAdd(2005.11.24)...
                        /*Item.mask = GVIF_TEXT|GVIF_FORMAT;
                        Item.row = i;
                        Item.nFormat = DT_LEFT|DT_WORDBREAK;
                        Item.strText = _T("");
                        Item.strText = m_pSet->m_OrgName; // PLM m_ColumnA

                         Item.col = COL_A; // PLM COL_A
                        m_pGrid->SetItem(&Item);*/


                        ///////////////////////////////////////////////////////////////////////////////////////////////
                        int nRow = m_pGrid->InsertRow("");
                        m_pGrid->SetItemText(nRow, 1, m_pSet->m_OrgName);
                        m_pGrid->SetItemData(nRow, 1, (DWORD)m_pSet->GetAbsolutePosition());
                ///////////////////////////////////////////////////////////////////////////////////////////////
                        sTemp = m_pSet->m_OrgCode.GetBuffer(0); // Code
                        iLength = sTemp.GetLength();            // Length of Code string
                        sTemp2 = sTemp.Left(2);                 // Get the first two character of the Code string
                        sTemp3 = sTemp.Right(3);                // Get the last three characters of the Code string
                        sTemp = sTemp2 + "-" + sTemp3;          // Concatenate the two string with the dash ex:A6-527

                        m_pGrid->SetItemText(nRow, 2, sTemp);                           // Ex: A6-527
                        m_pGrid->SetItemText(nRow, 3, m_pSet->m_Purpose);         // Ex: Interline Billings
                        m_pGrid->SetItemText(nRow, 4, m_pSet->m_OrgDiv);         // Ex: Cargo
                        m_pGrid->SetItemText(nRow, 5, m_pSet->m_ContactTitle); // Ex: Revenue Accounting
                        m_pGrid->SetItemText(nRow, 6, m_pSet->m_ContactName);  // Ex: Valine Pobitzer
                        m_pGrid->SetItemText(nRow, 7, m_pSet->m_Country);      // Ex: Austria

                        //sTemp = "mailto:" + m_pSet->m_Email1;
                        //m_pGrid->SetItemText(nRow, 8, sTemp);
                        m_pGrid->SetItemText(nRow, 8, m_pSet->m_Email1);         // Ex: valentin.pobitzer@airalps.at
                        if (m_pSet->m_Email1 != _T("")){
                              //Item.strText.Replace((char)0x3f, (char)0xa0);
                              m_pGrid->SetCellType(nRow, 8, RUNTIME_CLASS(CGridURLCell));
                        }

                        sStr = "";

                        /*** PLM 2006 Added/Modified
                        if (m_pSet->m_sectionb1) {sStr+="B1"; if (m_pSet->m_sectionb7||m_pSet->m_sectionb9) {sStr+=",";}}
                        if (m_pSet->m_sectionb7) {sStr+=" B7";if (m_pSet->m_sectionb9) {sStr+=",";}}
                        if (m_pSet->m_sectionb9) sStr+=" B9";*/

                        if (m_pSet->m_sectionb1) sStr+="B1"; // m_sectionb1 = 0

                        if (m_pSet->m_q_smart)                         // m_pSet->m_q_smart = 0
                        {
                                    if (sStr != "") {sStr+=",";}
                                    sStr += " B1-Q-SMART";
                        }
                        if (m_pSet->m_ssc)                               // m_pSet->m_ssc = 0
                        {
                                    if (sStr != "") {sStr+=",";}
                                    sStr += " B1-SSC";
                        }
                        if (m_pSet->m_sectionb7)                  // m_pSet->m_sectionb7 = 1
                        {
                              if (sStr != "") {sStr+=",";}    // STR = " B7"
                                    sStr += " B7";
                        }
                        if (m_pSet->m_sectionb9)                  // m_pSet->m_sectionb9 = 1
                        {
                                    if (sStr != "") {sStr+=",";}
                                    sStr += " B9";                        // STR = " B7, B9"
                        }
                        if (m_pSet->m_idec_sec)                        // m_pSet->m_idec_sec = 0
                        {
                                    if (sStr != "") {sStr+=",";}
                                    sStr += " B9-IDEC SEC";
                        }
                        if (m_pSet->m_asg)                              // m_pSet->m_asg = 0
                        {
                                    if (sStr != "") {sStr+=",";}
                                    sStr += " B14-ASG";
                        }
                        if (m_pSet->m_firstfinal)                  // m_pSet->m_firstfinal = 0
                        {
                                    if (sStr != "") {sStr+=",";}
                                    sStr += " B14-F&F";
                        }
                        if (m_pSet->m_racp)                              // m_pSet->m_racp = 0
                        {
                                    if (sStr != "") {sStr+=",";}
                                    sStr += " RAWG";
                        }

                        //*** PLM End

                        m_pGrid->SetItemText(nRow, 9, sStr);// STR = " B7, B9"
                        //m_lstCtrlAddresses.SetItemText(iActualItem, 8, sStr.GetBuffer(0));
                        
                  }
            }

            m_iLastPurposeID = m_pSet->m_purposeID; // 939
            //next record
            m_pSet->MoveNext();
            // m_pSet->m_purposeID : 1033
      }
      
      m_iLastPurposeID = 0;
      m_pGrid->Refresh();
   //TRACE("\nMATT is tracing the update of the grid: %s",sStr);

      
}

This will be easier the access database had 5 tables, now I have one csv file can someone help me get started this is my layout of the csv:

http://www.vbcity.com/forums/attachment.asp?id=17534

ASKER CERTIFIED SOLUTION
Avatar of agencysoft
agencysoft

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial