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();