The following are the Arrdictionary classes:
Public Class Arrdictionary
Private Objcollection as New Collection
Private Objdic as New dictionaryentry
Private strkey, strvalue as String
Public I as Integer
Public Function Item (ByVal Index as Integer) as Object
Try
Item = Objcollection.item (Index)
Catch ex as Exception
Item = "Error, no this!" "
End Try
End Function
Public Function Item (ByVal Key as String) as Object
Try
Item = Objcollection.item (Key)
Catch ex as Exception
Item = "Error, no this!" "
End Try
End Function
Public Sub Add (ByVal Key As String, ByVal Value as String)
Objdic.key = Key
Objdic.value = Value
Objcollection.add (Objdic, Objdic.key)
i + 1
End Sub
Protected Overrides Sub Finalize ()
Mybase.finalize ()
Objcollection = Nothing
Objdic = Nothing
strkey = ""
strvalue = ""
i = 0
End Sub
End Class
The following is the calling code snippet:
Dim Arrsql as New arrdictionary
Arrsql.add ("Receipt Number", Objexcelsheet.cells (t, 1). Value)
Arrsql.add ("House Address", Objexcelsheet.cells (T, 2). Value)
Arrsql.add ("Building Area", Objexcelsheet.cells (T, 3). Value)
Arrsql.add ("Room type", Objexcelsheet.cells (T, 4). Value)
Arrsql.add ("Orientation", Objexcelsheet.cells (T, 5). Value)
Arrsql.add ("Floors", objexcelsheet.cells (T, 6). Value)
Arrsql.add ("Production", Objexcelsheet.cells (T, 7). Value)
Arrsql.add ("Amount", Objexcelsheet.cells (T, 8). Value)
Arrsql.add ("area", Objexcelsheet.cells (T, 9). Value)
Arrsql.add ("Completion date", Objexcelsheet.cells (T, 10). Value)
Arrsql.add ("Service Life", Objexcelsheet.cells (t, 11). Value)
Arrsql.add ("Contacts", Objexcelsheet.cells (T, 12). Value)
Arrsql.add ("Input Person", objexcelsheet.cells (T, 13). Value)
Arrsql.add ("Entry Date", Objexcelsheet.cells (T, 14). Value)
Arrsql.add ("affiliated branch", Objexcelsheet.cells (T, 15). Value)
' Combine field names
Dim Columnsql as String
' Combine field values
Dim Valuesql as String
For I as Integer = 1 to Arrsql.i
Columnsql + = Arrsql.item (i). Key.tostring & ","
Valuesql + = "'" & Arrsql.item (i). Value.tostring & "',"
Next
' Combine SQL statements
Objcom.commandtext = "INSERT INTO Content" ("& Columnsql &") "& _
"Values (" & Valuesql & ")"
Columnsql = ""
Valuesql = ""
Arrsql = Nothing