This topic is locked

Custom Button - SQL UPDATE

4/27/2021 4:06:10 PM
ASPRunner.NET General questions
acacio.rapaz@fastdata.pt author

Good morning,
I'm trying to make a Custom Button on a line in the LIST of a table to perform an update on that same line where the "Pending" field changes the value from '0' to 1.
This in ASPRunner.NET Enterprise.
And another button on the same line that will show the VIEW or open the the VIEW.

img alt

![img alt](https://asprunner.com/forums/files/simplemdeUpload/Costum Button_as4ylol3.png)

Thanks.

admin 4/27/2021

I'm kind of miss the question. Please elaborte on what you asking.

acacio.rapaz@fastdata.pt author 4/27/2021

Thank you for your help,

Question 1:
I need to create a Costum Button in a List, in which the Costum Button is (in Image [Tratada]), execute in C # the Update of a field in the line (Pendente), then value '0' to value "1".
In SQL I know how to do it, but in ASPRUNNER I still don't understand how iet, I know it's in Costum Button (Server).

Eg SQL:

UPDATE Comunicacoes Set Pendente = '1' FROM Comunicacoes Where
IDComunicacoes = (Costum Button Line).

Another question:
The second Button [Ler] i need wen i press change from LISTO to VIEW of the the table.

Thanks

admin 4/28/2021

I understand what you need to do but I don't understand what kind of issue you having with it.

In either case, you can execute the same SQL query to update the record in the database in button's Server event. Another option is to use Database API

acacio.rapaz@fastdata.pt author 4/28/2021

img alt

Good afternoon,
Thanks for listening.

When I try to run SQL it gives me this error ??

And I don't know how to aim to stop the line in question where IDComunicaƧƵes = the line where the button is.
I'm doing something wrong.

But I am sure there is little left to understand the mechanics of the ASPRUNNER

Thanks.

admin 4/28/2021
You cannot simply add SQL to C# event. See the example link I sent you.
acacio.rapaz@fastdata.pt author 4/28/2021

img alt

I know but I get this error ....

I don't know what I'm doing wrong.

I'm putting the code in a Custom Button on the Server Side ....

acacio.rapaz@fastdata.pt author 4/28/2021

PHP:
$data = array();
$data["make"] = "Toyota";
$data["model"] = "RAV4";
$data["price"] = 16000;
DB::Update("cars", $data, "id=50" );

C#:
data = XVar.Clone(XVar.Array());
data.InitAndSetArrayItem("Toyota", "make");
data.InitAndSetArrayItem("RAV4", "model");
data.InitAndSetArrayItem(16000, "price");
DB.Update(new XVar("cars"), (XVar)(data), new XVar("id=50"));
return null;

If i convert PHP to C#, the error is this:

C:\inetpub\wwwroot\include\CommonEvents.cs(128,1): error CS0103: The name 'data' does not exist in the current context [C:\inetpub\wwwroot\FDGestWEBEventsCS.csproj]
C:\inetpub\wwwroot\include\CommonEvents.cs(129,4): error CS0103: The name 'data' does not exist in the current context [C:\inetpub\wwwroot\FDGestWEBEventsCS.csproj]
C:\inetpub\wwwroot\include\CommonEvents.cs(130,47): error CS0103: The name 'data' does not exist in the current context [C:\inetpub\wwwroot\FDGestWEBEventsCS.csproj]

admin 4/28/2021

Apologies, I have sent you PHPRunner manual link. Here is the one for ASPRunner.NET:
Database API

Also, if you simply need to execute a SQL query use DB.Exec