Can sumone please give me a helping hand here am trying to do a simple sql search were it will look all items in SQL database and pull up the names that match but am having a abit of trouble with it it brings all my accounts up regardless of there name can anyone help?
procedure TMainServer.SearchUserAccounts(const MyUserID, UserID, Token: String; rSocket: TWSocketClient);
var
search, msg: string;
begin
case StrToInt(Token) of
0: search := Trim(UserID);
1: search := Trim(UserID);
2: search := Trim(UserID);
end;
MyQuery.SQL.Text := 'SELECT * FROM users';
try
MyQuery.Open;
MyQuery.First;
while not (MyQuery.Eof) do begin
if (Token = '0') and ContainsText(MyQuery.Fields[1].AsString, search) then begin // check username
msg := '';
msg := msg + 'š24œ' + MyQuery.Fields[1].AsString + 'œ' + MyQuery.Fields[11].AsString + 'œ' + MyQuery.Fields[6].AsString + 'œ' + MyQuery.Fields[14].AsString + 'œ' + MyQuery.Fields[3].AsString + 'œ' + MyQuery.Fields[3].AsString + 'œ';
if msg > '' then
SocketSendCodedString(rSocket, msg);
end;
if (Token = '1') and ContainsText(MyQuery.Fields[14].AsString, search) then begin // check ip
msg := '';
msg := msg + 'š24œ' + MyQuery.Fields[1].AsString + 'œ' + MyQuery.Fields[11].AsString + 'œ' + MyQuery.Fields[6].AsString + 'œ' + MyQuery.Fields[14].AsString + 'œ' + MyQuery.Fields[3].AsString + 'œ' + MyQuery.Fields[3].AsString + 'œ';
if msg > '' then
SocketSendCodedString(rSocket, msg);
end;
if (Token = '2') and (MyQuery.Fields[11].AsString = search) then begin // check rank
msg := '';
msg := msg + 'š24œ' + MyQuery.Fields[1].AsString + 'œ' + MyQuery.Fields[11].AsString + 'œ' + MyQuery.Fields[6].AsString + 'œ' + MyQuery.Fields[14].AsString + 'œ' + MyQuery.Fields[3].AsString + 'œ' + MyQuery.Fields[3].AsString + 'œ';
if msg > '' then
SocketSendCodedString(rSocket, msg);
end;
MyQuery.Next;
end finally
MyQuery.Close;
end;
end;
thanks