| Products | Minisoft News | Events | Downloads | Product Manuals
 
  News

Minisoft News

Demo and Updates


Download an Evaluation today!

Updates

Release Notes (Jun 4, 2002)

Documentation


MiddleMan Manual

FAQ

   Product Review


Features

MSJOB

Using INETD_NT

MiddleMan
Application Samples

Know Problem Reports

Type Libraries

MDMDA

MDMFT

MDMFTP

MDMSA

 
   

Using Data Access - From VB with Arrays

The MDMDA session object is being called from a Visual Basic 5.0 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_002.gif (3919 bytes) 

Option Explicit
Dim ds As Object
Dim db As Object
Dim da As Object
Dim t1 As String
Const j1 = 6


Private Sub GetItemValues()

Dim ii As Integer

    t1 = ""
    ds.Item("ITEM-NO") = Text1.Text
    For ii = 0 To 11
        t1 = t1 + Right(" " + MISC(ii).Text,j1)
    Next ii
    Text2.Text = t1
    ds.Item("MISC") = t1

End Sub


Private Sub SetItemValues()

Dim ii As Integer

    Text1.Text = ds.Item("ITEM-NO")
    t1 = ds.Item("MISC")
    Text2.Text = t1
    For ii = 0 To 11
        MISC(ii).Text = Val(Mid(t1, (1 + (ii * j1)),j1))
    Next ii

End Sub


Private Sub Add_Click()

    GetItemValues

    If Not ds.DBPut(1, "@;") Then
        MsgBox ("DBPut failed: " + ds.errormessage)
        Exit Sub
    End If

End Sub


Private Sub Find_Click()

    If Not ds.DBFind(1, "PTYPE", tFind.Text) Then
        MsgBox ("DBFind failed: " + ds.errormessage)
        Exit Sub
    Else
        If Not ds.DBGet(5, "@;", "X") Then
            MsgBox ("DBGet failed: " + ds.errormessage)
            Exit Sub
        End If
    End If

    SetItemValues

End Sub


Private Sub Form_Load()

    Set da = CreateObject("MdmDA.Session")
    da.TraceLevel = 0
    da.HostAddress = "support"
    da.Port = "30002"
    da.LoginUser = "mgr"
    da.UserPassword = InputBox("user password")
    da.LoginGroup = "util"
    da.LoginAccount = "minisoft"
    If Not da.Connect Then
        MsgBox "Connect failed"
        Exit Sub
    End If
    If da.LoginStatus = False Then
        MsgBox "Login failed"
        Exit Sub
    End If
    Set db = da.AddImageDBRef("MSCARD")
    Set ds = db.AddDatasetRef("HISTORY")
    If Not db.DBOpen("MSCARD.UTIL.MINISOFT", "DO-ALL", 1) Then
        MsgBox "Open failed"
        Exit Sub
    End If
    ds.Delimiter = ""
    Next_Click
   
End Sub


Private Sub Next_Click()

    If Not ds.DBGet(2, "@;", "X") Then
        MsgBox ("DBGet failed: " + ds.errormessage)
        Exit Sub
    End If

    SetItemValues

End Sub


Private Sub Rewind_Click()

    ds.rewind

End Sub


Sample

[ sample5.zip]