• 软件测试技术
  • 软件测试博客
  • 软件测试视频
  • 开源软件测试技术
  • 软件测试论坛
  • 软件测试沙龙
  • 软件测试资料下载
  • 软件测试杂志
  • 软件测试人才招聘
    暂时没有公告

字号: | 推荐给好友 上一篇 | 下一篇

.NET中自己构建一个ArrDictionary

发布: 2007-7-01 11:09 | 作者: admin | 来源: | 查看: 12次 | 进入软件测试论坛讨论

领测软件测试网

以下是ArrDictionary类:
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 = "错误,无此项!"
        End Try
    End Function

    Public Function Item(ByVal Key As String) As Object
        Try
            Item = objCollection.Item(Key)
        Catch ex As Exception
            Item = "错误,无此项!"
        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


以下是调用代码段:
                Dim arrSQL As New ArrDictionary

                arrSQL.Add("收件号", objExcelSheet.Cells(t, 1).Value)
                arrSQL.Add("房屋地址", objExcelSheet.Cells(t, 2).Value)
                arrSQL.Add("建筑面积", objExcelSheet.Cells(t, 3).Value)
                arrSQL.Add("房型", objExcelSheet.Cells(t, 4).Value)
                arrSQL.Add("朝向", objExcelSheet.Cells(t, 5).Value)
                arrSQL.Add("楼层", objExcelSheet.Cells(t, 6).Value)
                arrSQL.Add("产别", objExcelSheet.Cells(t, 7).Value)
                arrSQL.Add("金额", objExcelSheet.Cells(t, 8).Value)
                arrSQL.Add("区域", objExcelSheet.Cells(t, 9).Value)
                arrSQL.Add("竣工日期", objExcelSheet.Cells(t, 10).Value)
                arrSQL.Add("使用年限", objExcelSheet.Cells(t, 11).Value)
                arrSQL.Add("联系人", objExcelSheet.Cells(t, 12).Value)
                arrSQL.Add("录入人", objExcelSheet.Cells(t, 13).Value)
                arrSQL.Add("录入日期", objExcelSheet.Cells(t, 14).Value)
                arrSQL.Add("所属分店", objExcelSheet.Cells(t, 15).Value)

                '组合字段名
                Dim ColumnSQL As String
                '组合字段值
                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

                '组合SQL语句
                objCom.CommandText = "insert into content(" & ColumnSQL & ")" & _
                "values(" & ValueSQL & ")"

                ColumnSQL = ""
                ValueSQL = ""
                arrSQL = Nothing

文章来源于领测软件测试网 https://www.ltesting.net/


关于领测软件测试网 | 领测软件测试网合作伙伴 | 广告服务 | 投稿指南 | 联系我们 | 网站地图 | 友情链接
版权所有(C) 2003-2010 TestAge(领测软件测试网)|领测国际科技(北京)有限公司|软件测试工程师培训网 All Rights Reserved
北京市海淀区中关村南大街9号北京理工科技大厦1402室 京ICP备10010545号-5
技术支持和业务联系:info@testage.com.cn 电话:010-51297073

软件测试 | 领测国际ISTQBISTQB官网TMMiTMMi认证国际软件测试工程师认证领测软件测试网