請告訴我如何解決代碼中的錯誤。我想從ms訪問表中獲取詳細信息。我已經將數據和描述用作列。日期是ms訪問中的主鍵。所以請讓我幫我讀取ms訪問表中的數據。如何在查詢表達式'date = 19apr2015'中刪除錯誤[Microsoft] [ODBC Microsoft Access Driver]語法錯誤(缺少運算符)。
try{
connect();
stmt = (Statement) conn.createStatement();
String sql, ks = " ";
ks = JOptionPane.showInputDialog("enter the date of which you want to read");
String jk = " where date=" + ks;
sql = "SELECT [date],[description] FROM Table2" + jk;
System.out.println("1");
rs = ((java.sql.Statement) stmt).executeQuery(sql);
if(rs.next())
{
String date1="hello",description1="hii";
date1 = rs.getString("date");
description1=rs.getString("description");
JOptionPane.showMessageDialog(null,"Date:"+date1+"\n"+description1);
}
else
{
JOptionPane.showMessageDialog(null,"Sorry the record does not exist");
try
{
close();
}
catch(Exception ea)
{
JOptionPane.showMessageDialog(null, "Error:"+ea.getMessage());
}
}
}
catch(Exception ew)
{
JOptionPane.showMessageDialog(null, "Unable to fetch Data");
JOptionPane.showMessageDialog(null,""+ew.getMessage());
System.out.println(""+ew);
}
感謝
修復您的格式,我會告訴你錯誤的原因! ;) – isnot2bad
什麼是格式化探針,它看起來不錯,我猜。 –
_現在不錯。 – isnot2bad