将数据填充到Android Studio中的微调器时出错

时间:2019-06-19 20:38:05

标签: android sql arrays spinner

我尝试使用android studio和SQLServer将数据填充到适配器,正在运行,但是当显示记录之一丢失时,我遇到了问题。 我不知道为什么!

在sql中,从unidades中选择placa,其中modelogps = 7; 节目: enter image description here 代码:

Statement comm = conecta().createStatement();
            ResultSet rs = comm.executeQuery("SELECT placa FROM unidades where modelogps=7;");
            if (rs.next()) {
                while (rs.next()) {
                    String id = rs.getString("placa");// value of database
                    data.add(id);
                    ArrayAdapter NoCoreAdapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1, data);
                    spinnerlista.setAdapter(NoCoreAdapter);
                }
            }

在微调节目中 TQ6, TQ5, UNAM, GPORT1, TRUCKL, TSM

1 个答案:

答案 0 :(得分:0)

删除if语句:

 if (rs.next())

因为它使结果集跳过第一行。
while (rs.next())就足够了。