Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / VB.NET / May 2006

Tip: Looking for answers? Try searching our database.

Export to excel without using office automation

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Agnes - 16 May 2006 15:03 GMT
I searched from previous post and got that there is a solution which export
the data to export without using Excel auotmation.

However, my database is SQL server, How can I amend objCmd.commandTest ??
I try the following insert statment but fail
"INSERT INTO [Sheet1$] SELECT * FROM
[ODBC;Driver={SQLServer};Server=(210.22.14.201);Database=DTS_ACCOUNT_HK;Trusted_Connection=yes].[arinvinfo];"

// Establish a connection to the data source.(copy from previous post)
System.Data.OleDb.OleDbConnection objConn = new
System.Data.OleDb.OleDbConnection(
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + m_strSampleFolder +
"Book7.xls;Extended Properties=Excel 8.0;");
objConn.Open();

// Add two records to the table named 'MyTable'.
System.Data.OleDb.OleDbCommand objCmd = new
System.Data.OleDb.OleDbCommand();
objCmd.Connection = objConn;
objCmd.CommandText = "Insert into MyTable (FirstName, LastName)" +
" values ('Bill', 'Brown')";
objCmd.ExecuteNonQuery();
objCmd.CommandText = "Insert into MyTable (FirstName, LastName)" +
" values ('Joe', 'Thomas')";
objCmd.ExecuteNonQuery();

// Close the connection.
objConn.Close();
Paul Clement - 16 May 2006 15:12 GMT
¤ I searched from previous post and got that there is a solution which export
¤ the data to export without using Excel auotmation.
¤
¤ However, my database is SQL server, How can I amend objCmd.commandTest ??
¤ I try the following insert statment but fail
¤ "INSERT INTO [Sheet1$] SELECT * FROM
¤ [ODBC;Driver={SQLServer};Server=(210.22.14.201);Database=DTS_ACCOUNT_HK;Trusted_Connection=yes].[arinvinfo];"
¤

What is the error?

Paul
~~~~
Microsoft MVP (Visual Basic)
Agnes - 16 May 2006 15:51 GMT
There is an error ODBC {SQLServer}(IP.....) connection fail

"Paul Clement" <UseAdddressAtEndofMessage@swspectrum.com>
???????:5bnj62l9ae805pq0t16f1q96bj198av4hn@4ax.com...

> ¤ I searched from previous post and got that there is a solution which
> export
[quoted text clipped - 13 lines]
> ~~~~
> Microsoft MVP (Visual Basic)
Paul Clement - 18 May 2006 18:12 GMT
¤ There is an error ODBC {SQLServer}(IP.....) connection fail
¤

That would seem to indicate a problem with the connection string or SQL Server configuration.

You might want to check out the connection string requirements for connecting via an IP address:

http://www.carlprothman.net/Default.aspx?tabid=90#ODBCDriverForSQLServer

Paul
~~~~
Microsoft MVP (Visual Basic)
Ken Tucker [MVP] - 16 May 2006 17:10 GMT
Agnes,

        Here is a link on how to create a spreadsheet with an xml
transform.  The sample is for a web application but will work with a windows
forms application.

http://support.microsoft.com/default.aspx?scid=kb;en-us;319180

Ken
--------------------

> I searched from previous post and got that there is a solution which export
> the data to export without using Excel auotmation.
[quoted text clipped - 24 lines]
> // Close the connection.
> objConn.Close();

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.