Click here to Skip to main content
15,887,267 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a visual basic form linked to a database and want to save each row and column of the database in an 2 dimensional array(,). If someone can help me with that code. The database is already linked.
Posted
Comments
Sandeep Mewara 15-Apr-11 8:44am    
Before asking for code, you should share your effort made till now.
Chris Maunder 15-Apr-11 9:30am    
If the poster has made no effort to help us answer his question then report the question and move on.
Sandeep Mewara 15-Apr-11 9:38am    
I did report at times and move on.
Just to notify user, I put a comment too if it helps.
Bovell 15-Apr-11 13:58pm    
Thank you for your comment. I am a first year VB student; not very versed on the appropriate language needed to explain myself. I am not so much looking for the detail code but trying to understand to logic so that I can figure out the code. So please be patient with me. I chose a two 2 dim array because I am more familiar with it. To answer your question as to what I have done so far, I have a search text box that searches through a specific column and once data is found shows all the fields in that row. I then set each row to equal to array and loop through to populate the array, but when I do if statement to check array, the array is empty. Thank you for any help in understanding what I am doing wrong
OriginalGriff 16-Apr-11 10:40am    
Sandeep passed your comment on to me, I think we need to see a code fragment to work out what you are doing, and what may be wrong with it!

1 solution

It's going to depend what you mean "The database is already linked". If it is connected to a control such as a DataGridView, then just iterate though the Rows collection, and copy it to the array.

Why are you trying to do this? Given that data from the database may be any datatype, you would almost certainly have to make this an array of object - which means it is difficult to use later. Instead, consider creating a class to hold the information, and use an array (or better a List<T>) of your class rather than a two dimensional array.

[edit]Typo: "or" instead of "of" - OriginalGriff[/edit]
 
Share this answer
 
v2
Comments
Sandeep Mewara 16-Apr-11 10:32am    
Comment from OP to me, sharing with you in case it helps:
Thank you for your comment. I am a first year VB student; not very versed on the appropriate language needed to explain myself. I am not so much looking for the detail code but trying to understand to logic so that I can figure out the code. So please be patient with me. I chose a two 2 dim array because I am more familiar with it. To answer your question as to what I have done so far, I have a search text box that searches through a specific column and once data is found shows all the fields in that row. I then set each row to equal to array and loop through to populate the array, but when I do if statement to check array, the array is empty. Thank you for any help in understanding what I am doing wrong

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