当我尝试从我的 MS 访问数据库中获取信息时,我不断收到同样的错误。下面是我的编码。
var
iTemp, iX, iY, k : Integer;
sDate : String;
begin
iTemp := 0;
DB.Close;
DB.SQL.Add('SELECT Count(UserID) AS Total FROM tblResults;');
DB.Parameters.ParamByName('ID').Value := pID;
DB.ExecSQL;
DB.Open;
iTemp := DB.FieldByName('Total').AsInteger;
if iTemp = 0 then
ShowMessage('Sorry but we do not have any test results for you. Take a test and check your result !')
else
Begin
DB.Close;
DB.SQL.Add('SELECT Mark,DateTested AS Total FROM tblResults WHERE UserID=:ID;');
DB.Parameters.ParamByName('ID').Value := pID;
DB.ExecSQL;
DB.Open;
for k := 1 to iTemp do
Begin
iX := k;
iY := DB.FieldByName('Mark').AsInteger;
sDate := DB.FieldByName('DateTested').AsString;
Chart1.Series[0].AddXY(iX,iY,sDate,clTeeColor);
DB.Next;
End;
Db.Close;
End;
错误是
语法错误。在查询表达式 'Username="SELECT Count(UserID) AS Total FROM tblResults'
我真的不理解这个错误。请帮我把这件事弄好。