Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

DELETE in Excel as Datasource VB.net OR workaround

Posted on 2014-11-03
3
Medium Priority
?
287 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 45

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 45

Accepted Solution

by:
AndyAinscow earned 2000 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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
In real business world data are crucial and sometimes data are shared among different information systems. Hence, an agreeable file transfer protocol need to be established.
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

886 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