By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,655 Members | 1,860 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,655 IT Pros & Developers. It's quick & easy.

Reading Excel file in VB.NET

P: 18
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
Share this Question
Share on Google+
5 Replies


RedSon
Expert 5K+
P: 5,000
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

P: 18
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
Expert 100+
P: 1,356
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

P: 18
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
Expert 100+
P: 1,356
Glad I could help.
Mar 15 '07 #6

Post your reply

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