Oracle Objects for OLE Release 9.2 Part Number A95895-01 |
|
The cmdCommitGrid_Click() procedure looks like:
Private Sub cmdCommitGrid_Click()
Dim OraSqlStmt As Object
Dim OraPArray(2) As Object
On Error GoTo err_CommitGrid
ErrMsg = ""
'Define parameter arrays, one for each column
OraDatabase.Parameters.AddTable "EMPNO_ARR", ORAPARM_INPUT, ORATYPE_NUMBER, NoOfRows
OraDatabase.Parameters.AddTable "ENAME_ARR", ORAPARM_INPUT, ORATYPE_VARCHAR2, NoOfRows, 10
OraDatabase.Parameters.AddTable "DEPTNO_ARR", ORAPARM_INPUT, ORATYPE_NUMBER, NoOfRows
If OraDatabase.LastServerErr <> 0 Or OraDatabase.LastServerErrText <> "" Then
Error 1
End If
'Initialize local array to hold parameter arrays
Set OraPArray(0) = OraDatabase.Parameters("EMPNO_ARR")
Set OraPArray(1) = OraDatabase.Parameters("ENAME_ARR")
Set OraPArray(2) = OraDatabase.Parameters("DEPTNO_ARR")
'Init the param array variables.
'Add loop to read thru grid ROWS
For ReadRow = 0 To (NoOfRows - 1)
Grid1.Row = ReadRow + 1
'Loop to read thru grid CELLS
For ReadCol = 0 To NoOfCols - 1
Grid1.Col = ReadCol
OraPArray(ReadCol).Put_Value Grid1.Text, ReadRow
Next ReadCol
Next ReadRow
'create a sqlstmt to insert array values into table
Set OraSqlStmt = OraDatabase.CreateSql("insert into emp(empno,ename,deptno) values(:EMPNO_ARR,:ENAME_ARR,:DEPTNO_ARR)", 0&)
If OraDatabase.LastServerErr <> 0 Or OraDatabase.LastServerErrText <> "" Then
ErrMsg = OraDatabase.LastServerErrText
Error 1
End If
'Refresh the Dynaset
EmpDynaset.Refresh
Exit Sub
err_CommitGrid:
If ErrMsg <> "" Then
MsgBox ErrMsg
Else
MsgBox Error$
End If
End Sub
|
Copyright © 1994, 2002 Oracle Corporation. All Rights Reserved. |
|