CCH4UNIGUI Posted March 5, 2021 Share Posted March 5, 2021 Hi Sherzod In MainModule: EmployeeTable.CommandText:='select * from employee WHERE ID='''+ '8180'+'''' <Works perfectly ie EmployeeTable opens and only data where id=8180 is shown> In LoginForm: UniMainModule.cUsername:=UserNameUniEdit.Text; <input as 8180 & value verified in MainForm as 8180> <cUsername declared as public in MainModule> Problem in MainModule EmployeeTable.CommandText:='select * from employee WHERE ID='''+ cUserName+'''' <EmployeeTable opens with no data> EmployeeTable.CommandText:='select * from employee WHERE ID='QutotedStr(cUserName) <EmployeeTable opens with no data> EmployeeTable.CommandText:='select * from employee WHERE ID=cUserName <EmployeeTable does not open at all> Can someone assist in correcting the CommandText syntax Quote Link to comment Share on other sites More sharing options...
CCH4UNIGUI Posted March 5, 2021 Author Share Posted March 5, 2021 Just now, CCH4UNIGUI said: Hi Sherzod In MainModule: EmployeeTable.CommandText:='select * from employee WHERE ID='''+ '8180'+'''' <Works perfectly ie EmployeeTable opens and only data where id=8180 is shown> In LoginForm: UniMainModule.cUsername:=UserNameUniEdit.Text; <input as 8180 & value verified in MainForm as 8180> <cUsername declared as public in MainModule> Problem in MainModule EmployeeTable.CommandText:='select * from employee WHERE ID='''+ cUserName+'''' <EmployeeTable opens with no data> EmployeeTable.CommandText:='select * from employee WHERE ID='QutotedStr(cUserName) <EmployeeTable opens with no data> EmployeeTable.CommandText:='select * from employee WHERE ID=cUserName <EmployeeTable does not open at all> Can someone assist in correcting the CommandText syntax FYI, actual codes procedure TUniMainModule.UniGUIMainModuleCreate(Sender: TObject); begin EmployeeTable.Active:=False; //opened but no data EmployeeTable.CommandText:='select * from employee WHERE ID='''+ cUserName+'''' ; //works perfectly EmployeeTable.CommandText:='select * from employee WHERE ID='''+ '8180'+'''' ; //opened but no data EmployeeTable.CommandText:='select * from employee WHERE ID='+QuotedStr(cUsername) ; EmployeeTable.CommandText:='select * from employee WHERE ID='+cUsername ; EmployeeTable.Active:=True; end; Quote Link to comment Share on other sites More sharing options...
CCH4UNIGUI Posted March 5, 2021 Author Share Posted March 5, 2021 Just now, CCH4UNIGUI said: FYI, actual codes procedure TUniMainModule.UniGUIMainModuleCreate(Sender: TObject); begin EmployeeTable.Active:=False; //opened but no data EmployeeTable.CommandText:='select * from employee WHERE ID='''+ cUserName+'''' ; //works perfectly EmployeeTable.CommandText:='select * from employee WHERE ID='''+ '8180'+'''' ; //opened but no data EmployeeTable.CommandText:='select * from employee WHERE ID='+QuotedStr(cUsername) ; EmployeeTable.CommandText:='select * from employee WHERE ID='+cUsername ; EmployeeTable.Active:=True; end; Solved. Will work on MainForm.OnCreate event Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.