Solved

DELETE in Excel as Datasource VB.net OR workaround

Posted on 2014-11-03
3
260 Views
Last Modified: 2014-11-04
I'm using Excel 2013 as a datasoure.  I am unable to perform DELETE commands on rows when using as a datasource.  I am using the following provider for my ADODB: Provider=Microsoft.ACE.OLEDB.12.0

Is there a way to perform a delete or an elegant workaround?   Can I perform a SELECT statement and get the specific row of a record?  If so I could delete the row via VB.net.  Would prefer this to having to search through the table for a matching record.
0
Comment
Question by:HyperBPP
  • 2
3 Comments
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 40421129
>>I'm using Excel 2013 as a datasoure.

As that is NOT a database then your problem makes sense.
For solutions consider automating Excel (not via ADODB) or changing the datasource to a database (eg. Access or SQL Server) or just overwriting the contents of that row should that be acceptable.
0
 
LVL 6

Author Comment

by:HyperBPP
ID: 40421511
Is there a way to identify the target row without having to loop through every record?  Like is there a recordset select statement that can say which row number a record came from?

I'm not certain I understand what you mean by "Automating Excel"?  Is this embedded macro or the idea of directly accessing cells?  If the latter I still have the undesirable loop through every record.
0
 
LVL 44

Accepted Solution

by:
AndyAinscow earned 500 total points
ID: 40421569
Excel is not a database, functionality that one expects from a database might not exist or is only difficult to reproduce in Excel.

>>Is there a way to identify the target row without having to loop through every record?
Yes, but then again no.  Depends on what you have.

>>Automating Excel
When you have code like (air code):
ExcelApp app = ....
app.WorkSheet(0).Rows(5).Delete();
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now