title: How to select a specific column in an excel file worksheet and then store them into an SQL Server database using vb.net
body: <p>hello Actually I just want to store just specific columns into my excisting database(SQL server 2008) I have searched a lot of a way to store them but I really didn't find it, can any body help me please!</p>
  
  <p>Here is my code that I want to implement  </p>
  
  <pre><code>    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
  </code></pre>