Click here to Skip to main content
15,905,614 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello all,

Now this is either too simple to be asked by anyone, or its impossible, as ive been trawling google and can only find how to do it the other way around (i.e. send data TO a database)

I want to import each field in each row into a specific text box, but cannot for the life of me work it out. Suuuuurely this is fairly simple to do?

Sorry if it is a horrifically simple solution and im being a muppet, but thanks in advance for any help
Posted

1 solution

So if you do a query into a datatable, something like
SELECT * FROM MyTable

you will get basically a collection of rows with same amount of columns on each row. If you now loop through the Rows and Columns collections and add the values to an array of textbox's, wouldn't that work? Something like (pseudo):
Fill a datatable with a query
foreach datatable.row {
   foreach datatable.column {
      textboxlist.add(new textbox() {Text = Row.Column.Value })
   }
}
Place the textboxes to the form
 
Share this answer
 
v2
Comments
sk saini 12-Aug-11 7:27am    
Accurate answer.
Wendelius 12-Aug-11 11:41am    
Thanks :)
Member 8113010 16-Aug-11 3:19am    
I have attempted to do this, but it seems not to work. Could anyone provide a sample code in c#? thanks for the solution, im sure it is exactly what i need i just cant work it out at the moment
Member 8113010 17-Aug-11 7:10am    
nevermind, worked it out, and came up with a solution very similar to yours. thanks!
Wendelius 17-Aug-11 9:14am    
Glad it got solved :)

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