2012-08-05 27 views
0

我想做一個學分系統。如果有用戶信用「警告:你有信用!數量:[在列中的Jeton值]」,如果沒有用戶信用「警告:你沒有信用!我用MyDAC組件學分制數據庫(MyDAC)

傑頓:用戶信用列(在數據庫中)

如何做到這一點。?

我試圖讓

MyQuery1.Close; 
MyQuery1.SQL.Text :=' select* from uyeler '+ 
        'where nick=:0 and jeton=:1'; 

MyQuery1.Params[0].AsString:=Edit1.Text; 
MyQuery1.Params[1].AsString:=?must?; 

MyQuery1.open; 

If MyQuery1.RecordCount=0 Then 
    Begin 

    MessageDlg('warning: you have not credit!', mtWarning,[mbOK],0) 

End 
Else 
Begin 

    MessageDlg('warning: you have credit! quantity: (Jeton value in column)', mtWarning,[mbOK],0) 

End; 

回答

3

如果jeton領域是信用,你可以寫這樣的事情。

MyQuery1.Close; 
MyQuery1.SQL.Text :='select jeton from uyeler where nick=:0'; 
MyQuery1.Params[0].AsString:=Edit1.Text; 
MyQuery1.open; 

If (MyQuery1.IsEmpty) or (MyQuery1.FieldByName('jeton').AsDouble<=0) Then 
    Begin 
    MessageDlg('warning: you have not credit!', mtWarning,[mbOK],0) 
    End 
    Else 
    Begin 
    MessageDlg(Format('warning: you have credit! quantity: (%n)',[MyQuery1.FieldByName('jeton').AsDouble]), mtWarning,[mbOK],0); 
    end; 
+0

謝謝,但,[錯誤] Unit2.pas(101):未聲明的標識符: 'AsDouble' – Ankara 2012-08-05 18:54:05

+0

嘗試使用'AsFloat' – RRUZ 2012-08-05 18:55:42

+0

謝謝... :)使命complate。 – Ankara 2012-08-05 19:01:02