为什么我会收到 TADOQuery select 语句的错误?
Why am I getting an Error with TADOQuery select statement?
每次我尝试设置这个变量的标题时,它都会给我 "unspecified error" 并且我得出结论...
我尝试直接从 TADOQuery 设置标题,然后将值赋给一个变量,然后将其加载到标题,但无论哪种方式,我都会收到未指定的错误。
qry1.SQL.Text := 'SELECT Number of Games Owned FROM Users WHERE UserID = "' + sLoggedInUser + '";';
qry1.Open;
iCountGames := qry1['Number of Games Owned'];
lblUserGamesOwned.Caption := 'Games Owned: ' + IntToStr(iCountGames);
数据库设计:
Field Name Data Type Description
UserID Short Text Maximum characters is 6
FirstName Short Text Maximum characters is 25
LastName Short Text Maximum characters is 25
Cell Number Short Text Maximum characters is 10
Number of Games Owned Number Integer
我希望代码将值加载到变量中,然后使用该变量来设置TLabel的标题,但是发生的只是弹出未指定的错误,而TLabel保持不变。
我想您只需要用大括号括住列名:
SELECT [Number of Games Owned] FROM Users WHERE UserID = "' + sLoggedInUser + '";';
我还建议您使用参数传入 UserId
而不是修改查询字符串。
每次我尝试设置这个变量的标题时,它都会给我 "unspecified error" 并且我得出结论...
我尝试直接从 TADOQuery 设置标题,然后将值赋给一个变量,然后将其加载到标题,但无论哪种方式,我都会收到未指定的错误。
qry1.SQL.Text := 'SELECT Number of Games Owned FROM Users WHERE UserID = "' + sLoggedInUser + '";';
qry1.Open;
iCountGames := qry1['Number of Games Owned'];
lblUserGamesOwned.Caption := 'Games Owned: ' + IntToStr(iCountGames);
数据库设计:
Field Name Data Type Description
UserID Short Text Maximum characters is 6
FirstName Short Text Maximum characters is 25
LastName Short Text Maximum characters is 25
Cell Number Short Text Maximum characters is 10
Number of Games Owned Number Integer
我希望代码将值加载到变量中,然后使用该变量来设置TLabel的标题,但是发生的只是弹出未指定的错误,而TLabel保持不变。
我想您只需要用大括号括住列名:
SELECT [Number of Games Owned] FROM Users WHERE UserID = "' + sLoggedInUser + '";';
我还建议您使用参数传入 UserId
而不是修改查询字符串。