472,954 Members | 1,929 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,954 software developers and data experts.

Accessing Excel Data in the Query using c# ,.net 2003 and sql 2000

I want to Open an excel sheet , then I want to loop through the rows in the excel sheet and should execute an update query for all the rows where the where condition in the query should match the columns of the excel sheet.
Eg:
Update Employee set Dept= AAA where employeenumbers= Excelsheet firstcolumn
So I want to loop this query for all the rows in the excel data.
The excel sheet will contain only employee numbers as the first column
The where condition can be for any columns in the excel sheet.
i have already opened the excel sheet using the OLEDB .
Sep 19 '07 #1
1 3096
Hi,

You mentioned that you are using OLEDB to open an excel file so i dont need to explain the details about it. to filter the information in your excel file and to fill the dataset with that filtered records you may copy the code below for your reference.

string strSheetName="Sheet1"
System.Data.OleDb.OleDbDataAdapter MyCommand
MyCommand = New System.Data.OleDb.OleDbDataAdapter("select * from [" + strSheetName + "$]", MyConnection)
DS = New System.Data.DataSet
MyCommand.Fill(DS)

Regards,
Ruel


I want to Open an excel sheet , then I want to loop through the rows in the excel sheet and should execute an update query for all the rows where the where condition in the query should match the columns of the excel sheet.
Eg:
Update Employee set Dept= AAA where employeenumbers= Excelsheet firstcolumn
So I want to loop this query for all the rows in the excel data.
The excel sheet will contain only employee numbers as the first column
The where condition can be for any columns in the excel sheet.
i have already opened the excel sheet using the OLEDB .
Sep 19 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: RK | last post by:
Hi, In my application, I need to copy data from an Excel file into a SQL table. The article related to this can be found at http://support.microsoft.com/default.aspx?scid=kb%3Ben-us%3B306572 ...
1
by: Tim | last post by:
Hi, I have a need to process a column of data and get information from SQL 2000 and return it to the Excel Spread Sheet. The data will be a list of order numbers in column 1. I need to look...
4
by: D | last post by:
I've created a report with many subreports of aggregate data. I want my client to be able to export this data to Excel to make her charts, etc. Only one problem: one of the fields is a "SchoolYear"...
0
by: Mike Knight | last post by:
(I've also posted this problem on microsoft.public.excel.programming) I have a MS Access 2003 Database named "AS400 Fields.mdb". This database contains links to tables on an AS400. In MS...
17
by: Mansi | last post by:
I need to do some research on how to use excel automation from c#. Does anyone know of any good books related to this subject? Thanks. Mansi
1
by: Barbara Alderton | last post by:
I’m relatively new to .NET. I would like to write a VB.NET app (I read that using C# isn't as elegant when dealing with Office products) that reads in Excel files (forms) of both 2000 and 2003...
3
by: Ian Dunn | last post by:
I'm simply trying to access an instance of Excel that has been opened manually by the user in order to put a few values in the existing sheet. Here's the code I've tried: Dim oXL As...
0
by: sradoff | last post by:
I wish to use XPath to access data from within an Excel generated XML Spreadsheet (generated with MS Excel 2003). I am using an asp Web page (not .NET, not at this time). I instantiate...
0
NeoPa
by: NeoPa | last post by:
Many of us have noticed that there are some very useful functions available to you when using Excel, but these same functions are not available, as standard, in Access. A particular issue I had...
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
1
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.