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