给你看看用VJ++6在Applet中写的代码:
try
{
if (System.getProperty("java.vendor").equals("Microsoft Corp."))
Class.forName("com.ms.jdbc.odbc.JdbcOdbcDriver");
else
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
dCon = DriverManager.getConnection("jdbc:odbc:MISforCorp","","");
dStm = dCon.createStatement();
        String msql= new String("SELECT id, DAY FROM Stationerylist WHERE id in (select min(id) from stationerylist where "+ para.trim() +"and person='"+loginName+"' group by day)order by day"); 
dRs = dStm.executeQuery(msql); 
         if(!dRs.next()) 
{
labStatus.setText("没有找到符合此条件的记录");
}

else
{  dRs = dStm.executeQuery(msql); 
   lstList.removeAll();
   hList.removeAll(); 

   while (dRs.next())
   {
lstList.addItem(dRs.getString("DAY").trim().substring(0,10)); 
    hList.addItem(dRs.getString("id"));   
        }
    labStatus.setText("记录已找到!"); 
}
  }
 catch(Exception ex)
  {
          labStatus.setText("查询条件有错");
 txfQuery.requestFocus(); 

 
   }