Click here to Skip to main content
16,019,273 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i am developing an application where i need to get values of two columns from database

id event date
1 abc 1-2-12
2 jkl 2-2-12

say event and dates,and show in list view like below,

abc........1-2-12
jkl...........2-2-12

how can i achieve this,thanks in advance!
Posted

1 solution

Just select the fields you want:
SQL
SELECT [event], [date] FROM myTable
instead of
SQL
SELECT * FROM myTable
You should avoid using wildcard field specifiers at all times - they increase bandwidth and can change or crash your application if the database is altered.

P.S. I only used the '[' and ']' around the column names because "date" is a reserved word in SQL and can stop your queries working when used as a column name. It's best to avoid using column names which are also reserved words!
 
Share this answer
 
Comments
azhar eqbal 28-Dec-12 10:42am    
@OriginalGriff,i have followed the same thing but i am trying to get these values i n an array or hashmap so that i could use that in listview..any suggestion?
OriginalGriff 28-Dec-12 10:54am    
How are you trying to connect to the DB? What classes are you using?

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