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.commandT est ??
I try the following insert statment but fail
"INSERT INTO [Sheet1$] SELECT * FROM
[ODBC;Driver={SQ LServer};Server =(210.22.14.201 );Database=DTS_ ACCOUNT_HK;Trus ted_Connection= yes].[arinvinfo];"
// Establish a connection to the data source.(copy from previous post)
System.Data.Ole Db.OleDbConnect ion objConn = new
System.Data.Ole Db.OleDbConnect ion(
"Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=" + m_strSampleFold er +
"Book7.xls;Exte nded Properties=Exce l 8.0;");
objConn.Open();
// Add two records to the table named 'MyTable'.
System.Data.Ole Db.OleDbCommand objCmd = new
System.Data.Ole Db.OleDbCommand ();
objCmd.Connecti on = objConn;
objCmd.CommandT ext = "Insert into MyTable (FirstName, LastName)" +
" values ('Bill', 'Brown')";
objCmd.ExecuteN onQuery();
objCmd.CommandT ext = "Insert into MyTable (FirstName, LastName)" +
" values ('Joe', 'Thomas')";
objCmd.ExecuteN onQuery();
// Close the connection.
objConn.Close() ;
the data to export without using Excel auotmation.
However, my database is SQL server, How can I amend objCmd.commandT est ??
I try the following insert statment but fail
"INSERT INTO [Sheet1$] SELECT * FROM
[ODBC;Driver={SQ LServer};Server =(210.22.14.201 );Database=DTS_ ACCOUNT_HK;Trus ted_Connection= yes].[arinvinfo];"
// Establish a connection to the data source.(copy from previous post)
System.Data.Ole Db.OleDbConnect ion objConn = new
System.Data.Ole Db.OleDbConnect ion(
"Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=" + m_strSampleFold er +
"Book7.xls;Exte nded Properties=Exce l 8.0;");
objConn.Open();
// Add two records to the table named 'MyTable'.
System.Data.Ole Db.OleDbCommand objCmd = new
System.Data.Ole Db.OleDbCommand ();
objCmd.Connecti on = objConn;
objCmd.CommandT ext = "Insert into MyTable (FirstName, LastName)" +
" values ('Bill', 'Brown')";
objCmd.ExecuteN onQuery();
objCmd.CommandT ext = "Insert into MyTable (FirstName, LastName)" +
" values ('Joe', 'Thomas')";
objCmd.ExecuteN onQuery();
// Close the connection.
objConn.Close() ;
Comment