Click here to Skip to main content
15,884,628 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
sir,
while i am using datagridview.columns.add(dr.getname(i),dr.getname(i)) which is in for loop .while i am executing i got an error like Index was outside the bounds of the array.actually i tried this from ur article "How to Populate a DataGridView Control using OleDbDataReader". please help me.
Posted
Comments
Menon Santosh 29-Oct-11 9:32am    
plz add your code for solution

1 solution

You shouldn't post this under Questions & Answers - if you got the code from an article, then there is a "new message" button at the bottom of that article, which causes an email to be sent to the author. They are then alerted that you wish to speak to them.
Posting this here relies on them "dropping by" and realising it is for them.

Having said that, a quick look at the article involved suggest that you haven't followed it very well - just copy'n'paste the bits you think are interesting without trying to understand the code itself.

Check your code: The loop in which you are incrementing i is not limited to the number of rows in the DataReader as it was in the example. As a result, i is exceeding the number of elements in teh reader and throwing an error as a result.

Try downloading the whole code, then use an online translator to convert it from C# to VB. I use http://www.developerfusion.com/tools/convert/csharp-to-vb/[^] when I need to convert code.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900