Inserting records into table on Grid: on applicationinit

Dear All,

I have the below code at applicationinit for a Grid. It compiles fine, but no records are inserted or displayed in the grid.

Any thoughts much appreciated.

Thank you.

Lyle


$sql=“INSERT INTO customers (firstname,lastname)
VALUES
(‘John’,‘Smith’);
(‘Gayle’,‘Jones’)”;

If this is the only line then yes, itwill not work because there’s no sqlexec here.

sc_exec_sql(sql);

On the other hand, to be able to use these macro’s there needs to be a connection set. I’m not quite sure but afaik there’s no such connection already available in the onapplicationinit. You must move the code to the onscriptinit. But be aware that this onscriptinit is ran on each refresh. The onapplicationinit is run only once.

Hi Albert,

sc_exec_sql worked fine. Must be that a connection existed due to being a grid app.

Thank you!!