Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

using Ado.net and MS Jet to insert rows in excel files

Status
Not open for further replies.

josecarlo

Programmer
Aug 22, 2000
30
PE
Hi,

I'm using Microsoft Jet and ADO.NET to insert rows into an excel file, something like this:

Dim SQL as String
SQL = "insert into tabla1 (F1,F2,F3,F4) values('a',1,'b',2)"
cmd.CommandText = SQL
cmd.ExecuteNonQuery()

where tabla1 is a named range in the excel file. But I want to do the same using unnamed ranges, something like this:

SQL = "insert into [Sheet1$A8:D8] (F1,F2,F3,F4) values('a',1,'b',2)"

why? because I want to make inserts of rows with different number of columns, and if I use named ranges it is not possible because I have to define the range previously.

So far, the statement has been working only if I put any value or character in the cells of the range by hand, for example:
A B C D
7
8 c 0 c 0
9

But, the statement doesn't work in ranges with no values in the cells.

Is there any way to do this?

I'll really really really appreciate your help.

Thanks

Jose Carlos




JOSE CARLOS ARAMBURU
josecarloaa@hotmail.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top