0

以下のシンテックスを使用しようとしていますが、機能していません。助けてください

var acccID = "acc";
    var date = (new Date().getMonth()+1)+"/"+new Date().getDate()+"/"+new Date().getFullYear();
    var dt1 = (new Date().getMonth()+1)+"/1/"+new Date().getFullYear();
    var dt2 = (new Date().getMonth()+1)+"/31/"+new Date().getFullYear();
    var cr = 5000;

$.mobile.eazydb.transaction(function(tx){
            tx.executeSql('INSERT INTO Ledger (Ledger_Account_ID, Ledger_Date, Ledger_Credit, Ledger_Memo)\
                    VALUES("'+acccID+'", "'+date+'", "'+cr+'", "Opening Balanace : Manish")', [],
                function(tx) { alert('ledger entry successfull.');  }, function(err) {   alert('error in inserted : '+err);  
            });
        });

$.mobile.eazydb.transaction(function(tx){
            tx.executeSql('SELECT * FROM Ledger WHERE Ledger_Date BETWEEN "'+dt1+'" AND "'+dt2+'" ORDER BY Ledger_Date DESC, Ledger_Credit', [],
                function(tx, rs){
                    if(rs.rows.length == 0) {
                        alert('No entries found');
                    } else {
                        for(var i = 0; i<rs.rows.length; i++) {
                            var row = rs.rows.item(i);
                            alert('A/C id : '+row['Ledger_Account_ID']+'\n'+
                                  'Ledger Date : '+row['Ledger_Date']+'\n'+
                                  'Ledger Credit : '+row['Ledger_Credit']+'\n'+
                                  'Ledger Memo : '+row['Ledger_Memo']);
                        }
                    }
            });
        });

それは警告するだけですNo entries found

4

3 に答える 3

0

バグはこのクエリにありますSELECT * FROM Ledger WHERE Ledger_Date BETWEEN "'+dt1+'" AND "'+dt2+'" ORDER BY Ledger_Date DESC, Ledger_Credit。SQL で日付範囲を選択する場合、日付は yyyy-mm-dd または yyyy/mm/dd 形式である必要があります。したがって、dt1 変数と dt2 変数が前述の形式であることを確認してください。上記の選択クエリを出力し、日付範囲の引数を調べます。たとえば、クエリは次のようになります

SELECT * FROM Ledger WHERE Ledger_Date BETWEEN "2013-10-01" AND "2014-11-01" ORDER BY Ledger_Date DESC
于 2013-07-08T09:06:01.783 に答える