0

こんにちは実際には、特定の列だけを既存のデータベース(SQLサーバー2008)に保存したいだけです。それらを保存する方法をたくさん検索しましたが、実際には見つかりませんでした。

これが私が実装したい私のコードです

    Public Class Form1
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

    Dim xlApp As Excel.Application
    Dim xlWorkBook As Excel.Workbook
    Dim xlWorkSheet As Excel.Worksheet
    Dim range As Excel.Range
    Dim rCnt As Integer
    Dim cCnt As Integer
    Dim Obj As Object

    xlApp = New Excel.Application
    xlWorkBook = xlApp.Workbooks.Open("C:\Downloads\B2012.xls")

    xlWorkSheet = xlWorkBook.ActiveSheet
    range = xlWorkSheet.UsedRange



    xlWorkBook.Close()
    xlApp.Quit()

    releaseObject(xlApp)
    releaseObject(xlWorkBook)
    releaseObject(xlWorkSheet)
End Sub

Private Sub releaseObject(ByVal obj As Object)
    Try
        System.Runtime.InteropServices.Marshal.ReleaseComObject(obj)
        obj = Nothing
    Catch ex As Exception
        obj = Nothing
    Finally
        GC.Collect()
    End Try
End Sub
End Class
4

1 に答える 1