Visual Basic

Moderators: None (Apply to moderate this forum)
Number of threads: 18011
Number of posts: 55384

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Export data to excel Posted by buyout on 9 May 2006 at 7:18 AM
how do i export data from visual basic to ms-excel be it the data is stored in an access database or sql database

Report
Re: Export data to excel Posted by Barkeeper on 9 May 2006 at 7:21 AM
This message was edited by Barkeeper at 2006-5-9 7:21:54

: how do i export data from visual basic to ms-excel be it the data is stored in an access database or sql database
:
:


Look up the SQL-Language --> "SELECT ... INTO .... "-Statement!
You'll need an installed ISAM-Driver for Excel! I have a example at home (at work right now). i will post it tomorrow.

Zvoni
------------------------------------------
Only stupidity of mankind and the universe
are infinite, but i'm not sure concerning
the universe. A. Einstein



Report
Re: Export data to excel Posted by Barkeeper on 9 May 2006 at 10:26 PM
Public Sub Export(ByVal Destination As String, ByVal ExtDatabase As String, ByVal ISAMType As String, Byval Source as String)
Dim DummySQL As String

    DummySQL = "SELECT * INTO [" & Destination & "] IN '" & ExtDatabase & "' '" & ISAMType & "' FROM " & Source

    'Here Code for Executing the SQL-Statement

End Sub

Public Sub ExportExcel()
Dim DummySQL As String

    DummySQL = "SELECT * INTO [Sheet1$] IN 'c:\test.xls' 'Excel 8.0;' FROM MySourceInDB"

    'Here Code for Executing the SQL-Statement

End Sub



: This message was edited by Barkeeper at 2006-5-9 7:21:54

: : how do i export data from visual basic to ms-excel be it the data is stored in an access database or sql database
: :
: :
:
:
: Look up the SQL-Language --> "SELECT ... INTO .... "-Statement!
: You'll need an installed ISAM-Driver for Excel! I have a example at home (at work right now). i will post it tomorrow.
:
: Zvoni
: ------------------------------------------
: Only stupidity of mankind and the universe
: are infinite, but i'm not sure concerning
: the universe. A. Einstein
:
:
:
:

------------------------------------------
Only stupidity of mankind and the universe
are infinite, but i'm not sure concerning
the universe. A. Einstein

Report
Re: Export data to excel Posted by awahi on 12 May 2006 at 7:06 AM
Hi Barkeeper

i tried the sql statment given by you (in query analyzer), but i get an error
Incorrect syntax near the keyword 'IN'.
the query was
SELECT * INTO [Sheet1$] IN 'c:\test.xls' 'Excel 8.0;' FROM ACNAME

did i do something wrong... ???

AWAHI

:
: Public Sub Export(ByVal Destination As String, ByVal ExtDatabase As String, ByVal ISAMType As String, Byval Source as String)
: Dim DummySQL As String
: 
:     DummySQL = "SELECT * INTO [" & Destination & "] IN '" & ExtDatabase & "' '" & ISAMType & "' FROM " & Source
: 
:     'Here Code for Executing the SQL-Statement
: 
: End Sub
: 
: Public Sub ExportExcel()
: Dim DummySQL As String
: 
:     DummySQL = "SELECT * INTO [Sheet1$] IN 'c:\test.xls' 'Excel 8.0;' FROM MySourceInDB"
: 
:     'Here Code for Executing the SQL-Statement
: 
: End Sub
: 
: 

:
: : This message was edited by Barkeeper at 2006-5-9 7:21:54

: : : how do i export data from visual basic to ms-excel be it the data is stored in an access database or sql database
: : :
: : :
: :
: :
: : Look up the SQL-Language --> "SELECT ... INTO .... "-Statement!
: : You'll need an installed ISAM-Driver for Excel! I have a example at home (at work right now). i will post it tomorrow.
: :
: : Zvoni
: : ------------------------------------------
: : Only stupidity of mankind and the universe
: : are infinite, but i'm not sure concerning
: : the universe. A. Einstein
: :
: :
: :
: :
:
: ------------------------------------------
: Only stupidity of mankind and the universe
: are infinite, but i'm not sure concerning
: the universe. A. Einstein
:
:

Report
Re: Export data to excel Posted by Barkeeper on 14 May 2006 at 10:23 PM
Sorry, my mistake.

the $-Character has to be left out.

SELECT * INTO [Sheet1] IN 'c:\test.xls' 'Excel 8.0;' FROM ACNAME

should do the trick. Note: Sheet1 not Sheet1$

I tried it with one of my own Access-Databases and it worked this way

Zvoni



: Hi Barkeeper
:
: i tried the sql statment given by you (in query analyzer), but i get an error
: Incorrect syntax near the keyword 'IN'.
: the query was
: SELECT * INTO [Sheet1$] IN 'c:\test.xls' 'Excel 8.0;' FROM ACNAME
:
: did i do something wrong... ???
:
: AWAHI
:
: :
: : Public Sub Export(ByVal Destination As String, ByVal ExtDatabase As String, ByVal ISAMType As String, Byval Source as String)
: : Dim DummySQL As String
: : 
: :     DummySQL = "SELECT * INTO [" & Destination & "] IN '" & ExtDatabase & "' '" & ISAMType & "' FROM " & Source
: : 
: :     'Here Code for Executing the SQL-Statement
: : 
: : End Sub
: : 
: : Public Sub ExportExcel()
: : Dim DummySQL As String
: : 
: :     DummySQL = "SELECT * INTO [Sheet1$] IN 'c:\test.xls' 'Excel 8.0;' FROM MySourceInDB"
: : 
: :     'Here Code for Executing the SQL-Statement
: : 
: : End Sub
: : 
: : 

: :
: : : This message was edited by Barkeeper at 2006-5-9 7:21:54

: : : : how do i export data from visual basic to ms-excel be it the data is stored in an access database or sql database
: : : :
: : : :
: : :
: : :
: : : Look up the SQL-Language --> "SELECT ... INTO .... "-Statement!
: : : You'll need an installed ISAM-Driver for Excel! I have a example at home (at work right now). i will post it tomorrow.
: : :
: : : Zvoni
: : : ------------------------------------------
: : : Only stupidity of mankind and the universe
: : : are infinite, but i'm not sure concerning
: : : the universe. A. Einstein
: : :
: : :
: : :
: : :
: :
: : ------------------------------------------
: : Only stupidity of mankind and the universe
: : are infinite, but i'm not sure concerning
: : the universe. A. Einstein
: :
: :
:
:

------------------------------------------
Only stupidity of mankind and the universe
are infinite, but i'm not sure concerning
the universe. A. Einstein

Report
Re: Export data to excel Posted by JaneW on 6 Mar 2011 at 10:55 PM
I find a way to use C# to export data to Excel.
And I get the method from a blog
http://janewdaisy.wordpress.com/2011/02/25/fast-export-data-from-database-to-excel-and-generate-chart-without-automation/
I think that the method in this blog may be useful for you, so I recommand it to you.
Hope Helpful!
Report
Re: Export data to excel Posted by susan11 on 14 Apr 2011 at 11:36 PM
all of what you said really helps me



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.