From
seems we can export the data to an excel by a simple query. However, I try
to amend that statement into "insert int [Sheet1$] select * from myInvoice
", HOwerver, it really doesn't work . Does anyone got idea ?Thanks alot
'Establish a connection to the data source.
Dim sConnectionStri ng As String
sConnectionStri ng = "Provider=Micro soft.Jet.OLEDB. 4.0;" & _
"Data Source=" & sSampleFolder & _
"Book7.xls;Exte nded Properties=Exce l 8.0;"
Dim objConn As New
System.Data.Ole Db.OleDbConnect ion(sConnection String)
objConn.Open()
'Add two records to the table.
Dim objCmd As New System.Data.Ole Db.OleDbCommand ()
objCmd.Connecti on = objConn
objCmd.CommandT ext = "Insert into [Sheet1$] (FirstName, LastName)" &
" values ('Bill', 'Brown')" <-- I try to amend
objCmd.ExecuteN onQuery()
objCmd.CommandT ext = "Insert into [Sheet1$] (FirstName, LastName)" &
" values ('Joe', 'Thomas')"
objCmd.ExecuteN onQuery()
'Close the connection.
objConn.Close()
seems we can export the data to an excel by a simple query. However, I try
to amend that statement into "insert int [Sheet1$] select * from myInvoice
", HOwerver, it really doesn't work . Does anyone got idea ?Thanks alot
'Establish a connection to the data source.
Dim sConnectionStri ng As String
sConnectionStri ng = "Provider=Micro soft.Jet.OLEDB. 4.0;" & _
"Data Source=" & sSampleFolder & _
"Book7.xls;Exte nded Properties=Exce l 8.0;"
Dim objConn As New
System.Data.Ole Db.OleDbConnect ion(sConnection String)
objConn.Open()
'Add two records to the table.
Dim objCmd As New System.Data.Ole Db.OleDbCommand ()
objCmd.Connecti on = objConn
objCmd.CommandT ext = "Insert into [Sheet1$] (FirstName, LastName)" &
" values ('Bill', 'Brown')" <-- I try to amend
objCmd.ExecuteN onQuery()
objCmd.CommandT ext = "Insert into [Sheet1$] (FirstName, LastName)" &
" values ('Joe', 'Thomas')"
objCmd.ExecuteN onQuery()
'Close the connection.
objConn.Close()
Comment