遇到了一个gridview需要绑定同一个数据库里几张表的数据的问题。
基本思路如下:
select * from 表一,表二 where 表一.id=表二.id 这是两张表的情况。
直接上代码:
<pre name="code" class="sql">string sqlstr = "select android.product_test_id ,android.experiment_id, android.android_staff, android.android_date,"+
"third_experiment.experiment_id,third_experiment.experiment_name,"+
"third_product_test.project_name,third_product_test.factory_name,third_product_test.product_type,third_product_test.sampl_batch "
+"from android, third_experiment, third_product_test where android.product_test_id=third_product_test.product_test_id and android.experiment_id=third_experiment.experiment_id";<pre name="code" class="sql">android,<pre name="code" class="html"><pre name="code" class="sql">third_experiment
<pre name="code" class="sql">third_product_test
是数据库名
其他的是字段名称
根据后面的级联匹配,可以正确的取出所需要的字段,并且绑定到gridview的列上。
本文介绍了如何在GridView中绑定同一数据库中多张表的数据。通过级联匹配,能够从不同表格中选取所需字段,成功展示在GridView的列上。
3604





