- Joined
- Apr 2, 2012
- Messages
- 94
- Reaction score
- 26
Code:
if not ZConnection1.Connected then
begin
di := ExtractFilePath(Application.ExeName)+'connect.dll';//mysql dll
ZConnection1.HostName := Trim(eIP.Text);
ZConnection1.User := Trim(eUser.Text);
ZConnection1.Password := Trim(ePass.Text);
ZConnection1.LibraryLocation := di;
ZConnection1.Protocol := 'mysqld-5';
ZConnection1.Database := Trim(eLoong_db.Text);
end;
ZConnection1.Connect;
if ZConnection1.Connected then
begin
ZQuery1.Active := False;
ZQuery1.SQL.Clear;
ZQuery1.SQL.Add('SELECT count(*) as total_Character from RoleData;');
ZQuery1.Connection:=ZConnection1;
ZQuery1.Active := True;
end;
if not ZConnection2.Connected then
begin
ZConnection2.HostName := Trim(eIP.Text);
ZConnection2.User := Trim(eUser.Text);
ZConnection2.Password := Trim(ePass.Text);
ZConnection2.LibraryLocation := di;
ZConnection2.Protocol := 'mysqld-5';
ZConnection2.Database := Trim(eLoong_login.Text);
end;
ZConnection2.Connect;
if ZConnection2.Connected then
begin
ZQuery2.Active := False;
ZQuery2.SQL.Clear;
ZQuery2.SQL.Add('SELECT count(*) as total_UserName from account;');
ZQuery2.Connection:=ZConnection2;
ZQuery2.Active := True;
end;
if ZConnection1.Connected AND ZConnection2.Connected then
begin
btn_connect.Caption:='Disconnect';
for i := 0 to PageControl1.ControlCount -1 do
PageControl1.Controls[i].Enabled:=True;
end;
Code:
Function TForm2.check_online(username:string = '';charname:string=''):Integer;
//Result 1 online
//Result 0 Ofline
//Result 2 Null
var qry:widestring;
i:integer;
begin
i:=0;
Result:=2;
ZQuery1.Active:=false;
ZQuery1.SQL.Clear;
qry:='SELECT AccountID FROM account_common WHERE AccountName= :Acc ';
ZQuery1.SQL.Add(qry);
ZQuery1.ParamByName('Acc').Value:=charname;
ZQuery1.Open;
ZQuery1.First;
while(not ZQuery1.EOF)do begin
if ZQuery1.Fields[0].AsInteger >= 1 then
begin
i := ZQuery1.Fields[0].AsInteger;
Break;
end;
ZQuery1.Next;
end;
ZQuery2.Active:=false;
ZQuery2.SQL.Clear;
qry:='SELECT login_status FROM account '+
' WHERE name=:na OR id= :ii ORDER BY login_status DESC LIMIT 1 ';
ZQuery2.SQL.Add(qry);
ZQuery2.ParamByName('na').Value:=username;
ZQuery2.ParamByName('ii').Value:=i;
ZQuery2.Open;
ZQuery2.First;
while(not ZQuery2.EOF)do begin
Result := ZQuery2.Fields[0].AsInteger;
ZQuery2.Next;
end;
end;
Attachments
You must be registered for see attachments list