我尝试使用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);
}
}
答案 0 :(得分:0)
删除if
语句:
if (rs.next())
因为它使结果集跳过第一行。
while (rs.next())
就足够了。