Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
object reference not released when using ADO.NET
Hi Experts,
I am using ado.net to export data to excel 2002 with oledb like the following (this a sample code from MSDN) -- Dim sConnectionString As String sConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=" & sSampleFolder & _ "Book7.xls;Extended Properties=Excel 8.0;" Dim objConn As New System.Data.OleDb.OleDbConnection(sConnectionStrin g) objConn.Open() 'Add two records to the table named 'MyTable'. Dim objCmd As New System.Data.OleDb.OleDbCommand() objCmd.Connection = objConn objCmd.CommandText = "Insert into [Sheet1$] (FirstName, LastName)" & _ " values ('Bill', 'Brown')" objCmd.ExecuteNonQuery() objCmd.CommandText = "Insert into [Sheet1$] (FirstName, LastName)" & _ " values ('Joe', 'Thomas')" objCmd.ExecuteNonQuery() 'Close the connection. objConn.Close() objConn.Dispose() objCmd = Nothing objConn = Nothing GC.Collect() I have two problems: 1) when the excel program is closed, there is still a reference to Excel listed under "Task Manager". What else do I need to do to clear that reference? 2) It seems there is no control to which row the first data set will be inserted. Data will be keeping inserted to the next row. Even you save the workbook and reoped, the new data will be inserted to the next empty row. Is there any way to tell the program the starting row? Thanks for your kind help -- jshen |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
ANN: XMLMax Virtual XML Editor Released | Excel Discussion (Misc queries) | |||
Is Excel 2007 released ? | New Users to Excel | |||
when is the next microsoft office excel going to be released? | Excel Discussion (Misc queries) | |||
Excel 12 - Information Released | Excel Programming | |||
excel not being released by vb.net | Excel Programming |