如何在数组中存储来自多列数据库的值并绑定到listview [英] How to store values from multiple columns of database in an array and bind the to listview

查看:75
本文介绍了如何在数组中存储来自多列数据库的值并绑定到listview的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个应用程序,我需要从数据库中获取两列的值



id event 约会

1 abc 1-2-12

2 jkl 2-2-12



说出事件和日期,并在列表视图中显示如下,



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

jkl ........... 2-2-12



我怎么能实现这一点,提前谢谢!

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!

推荐答案

只需选择您想要的字段:

Just select the fields you want:
SELECT [event], [date] FROM myTable

而不是

instead of

SELECT * FROM myTable

您应该始终避免使用通配符字段说明符 - 它们会增加带宽,并且如果数据库被更改,可能会更改或崩溃您的应用程序。



P.S.我只在列名周围使用''[''和'']'',因为date是SQL中的保留字,可以在用作列名时停止查询。最好避免使用也是保留字的列名!

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!


这篇关于如何在数组中存储来自多列数据库的值并绑定到listview的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆