How to add all the values of a column in a table to an array . Example : Lets say that I have a table, in that table there is a column named "Names" , how can I add all the names in that column to an array?
Asked
Active
Viewed 109 times
0
-
What are you looking for ? You showed a query which will do you what you are asking for what else you need ? – Krishna Apr 21 '17 at 13:09
-
Possible duplicate of [How do I find a value anywhere in a SQL Server Database?](http://stackoverflow.com/questions/436351/how-do-i-find-a-value-anywhere-in-a-sql-server-database) – daniell89 Apr 21 '17 at 13:09
-
So you want to search the entire database for a value and stick all the results into an array? This sounds like something is very wrong. This can take an exceptionally long time to retrieve and if there are lots of results the array could be staggeringly large. This type of searching is ok for occasional analysis but as a normal type of thing to run in an application it is is not ok. The performance alone is problematic, but the usage is questionable. Perhaps if you can share what you are trying to do we can help find an alternate solution. – Sean Lange Apr 21 '17 at 13:30
-
I will explain it in another way: How to add all the values of a column to an array . Example : Lets say that I have a table, in that table there is a column named "Names" , how can I add all the names in that column to an array? @SeanLange – Yamen Massalha Apr 21 '17 at 14:21
-
I will edit my question to explain it better – Yamen Massalha Apr 21 '17 at 14:21
-
Why do you want an array in c# anyway? A generic list or even a datatable would be easier to work with. – Sean Lange Apr 21 '17 at 14:23
-
I feel that it's easier for my project , my main problem is how to check all the fields in the sql table and if I found what Im searching for I save it anywhere @SeanLange – Yamen Massalha Apr 21 '17 at 14:28
-
Arrays in c# are horribly antiquated. Use a proper collection so you can manage it easier. Even a generic list of strings is better. Now that this question has morphed a bit it is really too broad now. There are thousands of examples of putting data from a database into a collection in c#. – Sean Lange Apr 21 '17 at 14:33
-
Ok , can you tell me how to get a value from sql table using c# ? @SeanLange – Yamen Massalha Apr 21 '17 at 14:36
-
Try this....https://www.google.com/search?q=how+to+get+a+value+from+sql+table+using+c%23+&ie=utf-8&oe=utf-8 – Sean Lange Apr 21 '17 at 14:36