800.682.0200 | FAX: 360.568.2923 |  About Us  |  Downloads  |  Manuals  |  Home  |  Index

 
 Middleware Applications
    JDBC JDBC/ UNIXMiddleMan ODBCODBC for Eloquence ODBC/UNIX OLE DB Provider for Image/Eloquence
   
News  

Minisoft News

 
Updates  

Download an Evaluation today!

Updates and New Features (Jun 4, 2002)


MiddleMan Manual

 

 
Product Review  

FAQ

Features

MSJOB

 
See Also...

MiddleMan
Application Samples

Know Problem Reports

Type Libraries

MDMDA

MDMFT

MDMFTP

MDMSA

 
  

Using Data Access - From VC++ with Arrays

  

The MDMDA session object is being called from a Microsoft VC++ application. This sample includes references to an item array (12J1).

The dataset and items are defined as follows:

ITEMS:
  ITEM-NO, Z6;
  SALES-PERIODS, 12X6;
  SALES-HISTORY, 12P12;
  MISC, 12J1;
  OTHER, J2;

SETS:
  NAME: HISTORY, DETAIL (1/18);
  ENTRY: ITEM-NO(!HISTORY-M),
    SALES-PERIODS,
    SALES-HISTORY,
    MISC,
    OTHER;
  CAPACITY: 101;
END.

MDM_001.gif (4055 bytes)

BOOL CVc01Dlg::OnInitDialog()
{
char buf[20];
BOOL b1;
COleException pError;

    CDialog::OnInitDialog();

    SetIcon(m_hIcon, TRUE);
    SetIcon(m_hIcon, FALSE);
   
    da = new IMdmdaDoc();
    b1 = da->CreateDispatch ( "MdmDA.Session", &pError );
    if ( !b1 ) {
        sprintf ( buf, "Session error: [x%08X]\0", pError.m_sc );
        AfxMessageBox ( buf );
        return TRUE;
    };
    da->SetTraceLevel ( 0 );
    da->SetHostAddress ( "support.minisoft.com\0" );
    da->SetPort ( 30002 );
    da->SetLoginUser ( "MGR" );
    da->SetLoginGroup ( "UTIL" );
    da->SetLoginAccount ( "MINISOFT" );
    da->SetUserPassword ( "abcdef" );
    if ( !da->Connect() ) {
        AfxMessageBox("couldn't connect...");
        return TRUE;
    };
    if ( !da->GetLoginStatus()) {
        AfxMessageBox("Login failed...");
        return TRUE;
    };
    db = new IImageDatabase();
    ds = new IImageDataset();
    db->AttachDispatch(da->AddImageDBRef("MSCARD"),true);
    ds->AttachDispatch(db->AddDatasetRef("HISTORY"),true);
    if ( !db->Open("MSCARD", "UTIL", "MINISOFT", 1, "DO-ALL") ) {
        AfxMessageBox("Open failed...");
        return TRUE;
    };
    ds->SetDelimiter ("\0");
    if ( !ds->ReadSerialNext("@;") ) {
        AfxMessageBox("ReadSerialNext failed...");
        return TRUE;
    };
    SetItemValues();

    return TRUE;
}

void CVc01Dlg::OnDestroy()
{
    CDialog::OnDestroy();
   
    if ( ds ) {
        ds->ReleaseDispatch();
        delete ds;
    }
    if ( db ) {
        db->ReleaseDispatch();
        delete db;
    }
    if ( da ) {
        da->ReleaseDispatch();
        delete da;
    }
}

void CVc01Dlg::SetItemValues()
{
    CString buf;
    char buf2[10];

    m_Edit1.SetWindowText(ds->GetItem("ITEM-NO"));
    buf = ds->GetItem("MISC");
    m_Edit2.SetWindowText(buf);
   
    sprintf ( buf2, "%d", atoi ( buf.Mid( 0, 6 ) ) );
    m_misc_1.SetWindowText ( buf2 );
    sprintf ( buf2, "%d", atoi ( buf.Mid( 6, 6 ) ) );
    m_misc_2.SetWindowText ( buf2 );
    sprintf ( buf2, "%d", atoi ( buf.Mid( 12, 6 ) ) );
    m_misc_3.SetWindowText ( buf2 );
    sprintf ( buf2, "%d", atoi ( buf.Mid( 18, 6 ) ) );
    m_misc_4.SetWindowText ( buf2 );
    sprintf ( buf2, "%d", atoi ( buf.Mid( 24, 6 ) ) );
    m_misc_5.SetWindowText ( buf2 );
    sprintf ( buf2, "%d", atoi ( buf.Mid( 30, 6 ) ) );
    m_misc_6.SetWindowText ( buf2 );
    sprintf ( buf2, "%d", atoi ( buf.Mid( 36, 6 ) ) );
    m_misc_7.SetWindowText ( buf2 );
    sprintf ( buf2, "%d", atoi ( buf.Mid( 42, 6 ) ) );
    m_misc_8.SetWindowText ( buf2 );
    sprintf ( buf2, "%d", atoi ( buf.Mid( 48, 6 ) ) );
    m_misc_9.SetWindowText ( buf2 );
    sprintf ( buf2, "%d", atoi ( buf.Mid( 54, 6 ) ) );
    m_misc_10.SetWindowText ( buf2 );
    sprintf ( buf2, "%d", atoi ( buf.Mid( 60, 6 ) ) );
    m_misc_11.SetWindowText ( buf2 );
    sprintf ( buf2, "%d", atoi ( buf.Mid( 66, 6 ) ) );
    m_misc_12.SetWindowText ( buf2 );

}

void CVc01Dlg::GetItemValues()
{
    CString buf;
    CString buf2;
    char buf3[10];

    m_misc_1.GetWindowText ( buf2 );
    sprintf ( buf3, "%6d", atoi ( buf2 ) );
    buf = buf3;
    m_misc_2.GetWindowText ( buf2 );
    sprintf ( buf3, "%6d", atoi ( buf2 ) );
    buf += buf3;
    m_misc_3.GetWindowText ( buf2 );
    sprintf ( buf3, "%6d", atoi ( buf2 ) );
    buf += buf3;
    m_misc_4.GetWindowText ( buf2 );
    sprintf ( buf3, "%6d", atoi ( buf2 ) );
    buf += buf3;
    m_misc_5.GetWindowText ( buf2 );
    sprintf ( buf3, "%6d", atoi ( buf2 ) );
    buf += buf3;
    m_misc_6.GetWindowText ( buf2 );
    sprintf ( buf3, "%6d", atoi ( buf2 ) );
    buf += buf3;
    m_misc_7.GetWindowText ( buf2 );
    sprintf ( buf3, "%6d", atoi ( buf2 ) );
    buf += buf3;
    m_misc_8.GetWindowText ( buf2 );
    sprintf ( buf3, "%6d", atoi ( buf2 ) );
    buf += buf3;
    m_misc_9.GetWindowText ( buf2 );
    sprintf ( buf3, "%6d", atoi ( buf2 ) );
    buf += buf3;
    m_misc_10.GetWindowText ( buf2 );
    sprintf ( buf3, "%6d", atoi ( buf2 ) );
    buf += buf3;
    m_misc_11.GetWindowText ( buf2 );
    sprintf ( buf3, "%6d", atoi ( buf2 ) );
    buf += buf3;
    m_misc_12.GetWindowText ( buf2 );
    sprintf ( buf3, "%6d", atoi ( buf2 ) );
    buf += buf3;

    m_Edit2.SetWindowText(buf);
    ds->SetItem("MISC",buf);
    m_Edit1.GetWindowText(buf2);
    ds->SetItem("ITEM-NO",buf2);
   
}

void CVc01Dlg::OnNext()
{
    if ( !ds->ReadSerialNext("@;") ) {
        AfxMessageBox("ReadSerialNextfailed...");
        return;
    };

    SetItemValues();

    return;
}

void CVc01Dlg::OnRewind()
{
    if ( !ds->Rewind() ) {
        AfxMessageBox("Rewind failed...");
        return;
    };
}

void CVc01Dlg::OnAdd()
{
    GetItemValues();

    if ( !ds->Write("@;") ) {
        AfxMessageBox("Write failed...");
        return;
    };

    return;

   

 

Minisoft Inc.  1024 First Street Snohomish, WA 98290  Phone: (800) 682-0200  Fax: (360) 568-2923
 Copyright ©2008 Minisoft, Inc.   
License Agreement