Hi,
I need to export the data from the database to the Excel sheet and vice-versa in windows application. Any help?
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Vijay YadavRank #1,637 · 943 reputationPosted Jan 19, 2012, 1:44 AM EST
Faisal AnsariRank #3,366 · 427 reputationPosted Jan 19, 2012, 2:48 AM EST
dear how did you do this can you provide me your ideas about this ... ?
Dhaval PatelRank #1,023 · 1.9K reputationPosted Jan 19, 2012, 3:08 AM EST
Please use this
Dim cn As ADODB.Connection Dim strSQL As String Dim lngRecsAff As Long Set cn = New ADODB.Connection cn.Open "Provider=SQLOLEDB;Data Source=;" & _ "Initial Catalog=;User ID=;Password=" 'Import by using OPENDATASOURCE. strSQL = "SELECT * INTO XLImport6 FROM " & _ "OPENDATASOURCE('Microsoft.Jet.OLEDB.4.0', " & _ "'Data Source=C:\test\xltest.xls;" & _ "Extended Properties=Excel 8.0')...[Customers$]" Debug.Print strSQL cn.Execute strSQL, lngRecsAff, adExecuteNoRecords Debug.Print "Records affected: " & lngRecsAff 'Import by using OPENROWSET and object name. strSQL = "SELECT * INTO XLImport7 FROM " & _ "OPENROWSET('Microsoft.Jet.OLEDB.4.0', " & _ "'Excel 8.0;Database=C:\test\xltest.xls', " & _ "[Customers$])" Debug.Print strSQL cn.Execute strSQL, lngRecsAff, adExecuteNoRecords Debug.Print "Records affected: " & lngRecsAff 'Import by using OPENROWSET and SELECT query. strSQL = "SELECT * INTO XLImport8 FROM " & _ "OPENROWSET('Microsoft.Jet.OLEDB.4.0', " & _ "'Excel 8.0;Database=C:\test\xltest.xls', " & _ "'SELECT * FROM [Customers$]')" Debug.Print strSQL cn.Execute strSQL, lngRecsAff, adExecuteNoRecords Debug.Print "Records affected: " & lngRecsAff cn.Close Set cn = Nothing http://support.microsoft.com/kb/321686 Thanks & Regards Dhaval Patel This post help you than mark as "Accepted Answer"Prabhu RajaRank #861 · 2.6K reputationPosted Jan 19, 2012, 6:40 AM EST
Hope this Will help you
http://www.dotnetheaven.com/UploadFile/rahul4_saxena/DataInExcelSheet0530
2007080823AM/DataInExcelSheet.aspx
Thank You