473,326 Members | 2,114 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Reading Excel file in VB.NET

Hi all,
I'm reading an excel file in VB.net. It works fine if I don't give any condition in the 'where' claus. My code is
Expand|Select|Wrap|Line Numbers
  1. Dim myDataset As New DataSet()
  2. Dim strConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\test.xls;Extended Properties=Excel 8.0;"
  3. Dim myData As New OleDbDataAdapter("SELECT * FROM [Sheet1$] where t_id='5'", strConn)
  4. myData.TableMappings.Add("Table", "ExcelTest")
  5. myData.Fill(myDataset)
  6.  
Please let me know how do I use the where condition while reading the excel file.


Thanks a lot,

Regards,
SC
Mar 15 '07 #1
5 6061
RedSon
5,000 Expert 4TB
This is probably a better question for the SQL forums. You are asking about syntax for the SQL WHERE command.

Hopefully someone in this forum will be able to help you with your commands.
Mar 15 '07 #2
Hi,
Thanks for the reply. Waiting for anyone to answer me. I put this in this forum as it was more to do with the OleDbDataAdapter syntax, rather than SQL syntax.

Thanks Again,
SC

This is probably a better question for the SQL forums. You are asking about syntax for the SQL WHERE command.

Hopefully someone in this forum will be able to help you with your commands.
Mar 15 '07 #3
Denburt
1,356 Expert 1GB
um t_id='5' I think this may be your problem is the id field a number type or text type if text it should work if number then remove the quotes:

t_id= 5
Mar 15 '07 #4
HI,
Thanks a lot. Its fine now. I had to remove the quotes.

Thanks again.
SC


um t_id='5' I think this may be your problem is the id field a number type or text type if text it should work if number then remove the quotes:

t_id= 5
Mar 15 '07 #5
Denburt
1,356 Expert 1GB
Glad I could help.
Mar 15 '07 #6

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

Similar topics

0
by: David Alliet | last post by:
Hello, I'm having a bit of a problem with ASP and Excel. A client has developed his own program, which calculates alot of financial stuff, in excel. I'm doing his websites and he has requested...
1
by: mail2atulmehta | last post by:
Hi, I do not know if this is right place for this, but i need some help. I have a text file, whose values are seprated by a delimiter. I want to open this file in excel, ( not import it) . I have...
1
by: Turner, GS \(Geoff\) | last post by:
> -----Original Message----- > From: siliconwafer > Posted At: 19 August 2005 15:20 > Posted To: c > Conversation: reading an excel file in C? > Subject: reading an excel file in C? > > >...
4
by: Phoebe. | last post by:
Hi, Good Day! Reading 1 excel file into a dataset is fine. How can I read multiple excel with the same data structure into 1 dataset? How can I append those data? Can someone help? Thanks in...
5
by: Scott M. Lyon | last post by:
I've just discovered a bug in some code I wrote a little while ago, and I need you guys' help to fix it. My program imports data from a standard Excel Spreadsheet (just with specific column...
9
by: dba123 | last post by:
I need some help and direction on what classes and an example or two (article) on how to read an Excel Worksheet and insert one column into a database table column. I am using .NET 2.0 only. What...
3
by: Brad | last post by:
I'm having a problem reading data from an Excel file into a dataset. Can anybody give me an idea of what's happening? I've included the problematic source and the error message to the end of this...
3
by: Bharathi | last post by:
Hi, I got strucked with reading date value from excel file using C#.NET. For Jan-2000 the value I am getting is 36526.0. For all other dates also I am getting some double value like this. ...
1
by: sachinkale123 | last post by:
Hi, I am reading excel file and reading values from that I am using provider As : "Provider=Microsoft.Jet.OLEDB.4.0;Data Source = " + Filename + ";Extended Properties=\"Excel 8.0;Hdr=No;IMEX=1\"";...
1
by: ndedhia1 | last post by:
I was reading in a log file like this that had no milliseconds: QuoteBlockTiming exceeded 1 ms: 1 --- Thu Dec 10 02:01:40 CST 2009 170.137.15.155 Class key = 601650761 block size QuoteBlockTiming...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.