小總1·

1 tex2=new JTextField("",15);賦值爲空
  if(tex2.getText()!=""&&tex2.getText() !=null)
正確寫法如下(判斷string不爲空
  tex1.getText()!=null&&!tex1.getText().equals("")

2 在我們平時的SQL數據庫操作中,更新數據是最常見的了,下面就將爲您介紹使用使用SQL中的Update更新多行數據的方法,供您參考。
Update 語句用於更新單表中選定行的一列或多列的值。要更新的目標表在語句中定義, Set 子句則指定要更新哪些列並計算他們的值。 Update 語句總是包含 Where 語句,而且 Update 語句比較危險,所以您必須明確地認識到 Where 語句的重要性, Where 語句被用來指定需要更新的行。
標準語法:
UPDATE table_name
SET columnname1 = value1
[, columname2 = value2]...
WHERE search_condition
以下是一個簡單的 Update 語句的例子 :
Update customers
Set credit=100000.00,id=99
Where name='asp'
在此例中我們將表 customers 中客戶名爲 asp 的客戶的信貸值更新爲 10 萬並將他的 ID 變更爲 99。再看下例:

Update customers
Set credit=200000.00,state=021
Where ID in (80,90,100,120)
我們可以發現,其實 SQL 處理 Update 語句的過程就是逐行遍歷所指定的表,更新其搜索條件結果爲“真”的行,跳過其搜索條件結果爲“假”或“空”的行。


3   String sql = "select evenId,resetDate,evenNum,evenTitle,filePath,filePath1 from informations where ";
                if (eventitle != "") {
                        sql += "evenTitle like '%" + eventitle + "%' and ";
                }
                if(evennum!=""){
                        sql += "evenNum like '%" + evennum + "%' and ";
                }
                if(strdate!=""){
                         SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
                         Date startDate = sdf.parse(strdate);
                         String sdf1 = sdf.format(startDate);
                        sql += "resetDate>='"+sdf1+"' and ";
                }
                if(enddate!=""){
                         SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
                         Date endDate = sdf.parse(enddate);
                         String sdf1 = sdf.format(endDate);
                        sql += "resetDate<='"+sdf1+"' and ";
                }
        if(sql.endsWith("and ")){
                sql = sql.substring(0,sql.lastIndexOf("and")-1);   //substring截取and
        }
[/size]
發佈了173 篇原創文章 · 獲贊 4 · 訪問量 5萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章