Export Sql server 2008 Table to Excel using vb2010

  • Thread starter Thread starter Anbu rose
  • Start date Start date
A

Anbu rose

Guest
Private Sub CmdExToExcel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmdExToExcel.Click
Call Sqlconn.Main()
Dim objcn As New SqlConnection(cnn)
Dim objcmd As SqlCommand
objcmd = New SqlCommand
Dim aa As String

objcmd.CommandText = "INSERT INTO OPENROWSET('Microsoft.ACE.OLEDB.12.0'," & _
"'$Excel 12.0;Database=c:\123.xlsx','SELECT * " & _
"FROM [Sheet1$]') SELECT * from attendance"
objcn.Open()
objcmd.ExecuteNonQuery()

End Sub


i like to export bulk data from sql to excel. please help me, correct the error



Regards

Anburose

Continue reading...
 
Back
Top