Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
A follow up on the design
Message
From
19/01/2006 17:35:27
 
 
To
19/01/2006 17:15:15
General information
Forum:
ASP.NET
Category:
Databases
Miscellaneous
Thread ID:
01088691
Message ID:
01088710
Views:
7
>But, an ArrayList can hold any object, so you could have an ArrayList of two-dimensional arrays. Or, you can create a class containing two members (a key and a value) and have an ArrayList of this class.

Ok, in this approach, I have adjusted the definition for an arraylist. Then, I can have a better way to add and clear the parameters. But, the question is how I can add them to the data adapter parameter object. I am not sure about the syntax.
Imports System.Data
Imports System.Data.Common
Imports System.Data.OleDb
Imports System.Data.SqlClient
Imports System.Data.Odbc

Public Class Data

    Public oDataSet As DataSet
    Public oDataView As DataView
    Public cSQL As String
    Public cConnectionString As String
    Public nCount As Integer
    Public nSQLMode As Integer = Framework.App.nSQLMode
    Private oConnection As IDbConnection = Nothing
    Private oDataAdapter As IDbDataAdapter = Nothing
    Private oCommand As IDbCommand = Nothing
    Private oDataParameter As IDbDataParameter = Nothing
    Private oParameters As ArrayList
    Private oParameters2 As New Collection

    ' SQL exec
    ' expC1 SQL command
    ' expO1 Connection
    Public Function SQLExec(ByVal tcSQL As String, ByVal tcConnection As String) As Boolean
        InitializeDataObject(nSQLMode, tcConnection, tcSQL)
.
.
.

    Public Function InitializeDataObject(ByVal tnConnType As Integer, ByVal tcConnection As String, _
     ByVal tcSql As String) As IDbConnection
        Dim lnCounter As Integer
        Dim loParameter As Object
        cConnectionString = tcConnection
        cSQL = tcSql
        Select Case tnConnType
            Case 1
                oConnection = New OleDbConnection(tcConnection)
                oDataAdapter = New OleDbDataAdapter
                oCommand = New OleDbCommand
                oDataParameter = New OleDbParameter
                For Each loParameter In oParameters
                    oParameters2.Add(New OleDbParameter(????????)
                Next
            Case 2
                oConnection = New SqlConnection(tcConnection)
                oDataAdapter = New SqlDataAdapter
                oCommand = New SqlCommand
                oDataParameter = New SqlParameter
                For lnCounter = 1 To nParameter
                    oParameters2.Add(New SqlParameter(oParameters(lnCounter, 1).ToString, oParameters(lnCounter, 2)))
                Next
            Case 3
                oConnection = New OdbcConnection(tcConnection)
                oDataAdapter = New OdbcDataAdapter
                oCommand = New OdbcCommand
                oDataParameter = New OdbcParameter
                For lnCounter = 1 To nParameter
                    oParameters2.Add(New OdbcParameter(oParameters(lnCounter, 1).ToString, oParameters(lnCounter, 2)))
                Next
        End Select
        Return oConnection
    End Function

    ' Add a parameter
    ' expC1 Field
    ' expO1 Value
    Public Function ParameterAdd(ByVal tcField As String, ByVal toValue As Object) As Boolean
        Dim oParameter(1, 2) As Object
        oParameter(1, 1) = "@" + tcField
        oParameter(1, 2) = toValue
        oParameters.Add(oParameter)
    End Function

    ' Clear the parameter
    ' This is needed is you are doing multiple loDataProvider SQL calls in a row such as a SQLExec()
    ' followed by a SQLUpdate() and you have defined a parameter for the SQLExec() that you don't need
    ' for the SQLUpdate().
    Public Function ParameterClear() As Boolean
        oParameters.Clear()
        oParameters2.Clear()
    End Function

End Class
After having done this, the line with the ??????? is the one I need to complete. This is always the most difficult one. :)
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Previous
Reply
Map
View

Click here to load this message in the networking platform