How to do it in asp.net ( Insert)

This public forum is for user-to-user discussions of ASP.NET Maker. Note that this is not support forum.
Post Reply
VanessaOlimpio
User
Posts: 9

How to do it in asp.net ( Insert)

Post by VanessaOlimpio »

I did it in php maker how can I use the same line of reasoning to ASP.NET MAKER

$xba = ew_Execute("set IDENTITY_INSERT Ocr on");
$ocr = ew_Execute("INSERT INTO Ocr (idOcr,CodOpm,Tit,DtFto,Stat,Ende,Ocr,Nat,HrFto,DP,TipLoc,Obs,His,Edit,UTMX,UTMY,CPA,UserInc,DtInc) SELECT idOcr,CodOpm,Tit,DtFto,Stat,Ende,Ocr,Nat,HrFto,DP,TipLoc,Obs,His,Edit,UTMX,UTMY,CPA,UserInc,DtInc FROM Ocr_deletado WHERE idOcr=" . $rs["idOcr"]);
$xba2 = ew_Execute("set IDENTITY_INSERT Ocr off");


motfs
User
Posts: 258

Post by motfs »

You can use ew_Execute() (or Conn.Execute()) to execute the SQL statement. See the Server Event and Client Scripts (Examples) in help file for more details. Try to convert the code first and post the code if you encounter issue.


VanessaOlimpio
User
Posts: 9

Post by VanessaOlimpio »

Had already trying to utilize this option however gave error in execution.

string sInsertSql = "INSERT INTO rac.HisAtual (UserInc)values(" + ew_AdjustSql(CurrentUserName()) + ") WHERE IdOcr="+IdOcr.CurrentValue;

ew_Execute(sInsertSql);
return true;


motfs
User
Posts: 258

Post by motfs »

VanessaOlimpio wrote:
string sInsertSql = "INSERT INTO rac.HisAtual (UserInc)values(" + ew_AdjustSql(CurrentUserName())

  • ") WHERE IdOcr="+IdOcr.CurrentValue;

You need to check if your SQL is valid. Use ew_End("<SQL>"); to check.

Is this field "IdOcr" a primary key? Insert into different table?


VanessaOlimpio
User
Posts: 9

Post by VanessaOlimpio »

Good afternoon !
I did not understand the proposal. Could you explain in more detail?

  • Field " IdOcr " is a primary key
    And I need to insert updates on the table if the field " IdOcr " equals true.
  • The amount I need Insert is contained in CurrentUserName ( )

motfs
User
Posts: 258

Post by motfs »

VanessaOlimpio wrote:
And I need to insert updates on the table if the field " IdOcr " equals true.

If IdOcr is a primary key, it should be unique why equal true.
If the record exist, you need to perform an Update Statement NOT Insert Statement. You need to provide the error message as well if you want other user to provide input/comment.

You need to check if your SQL is valid. Use ew_End("<SQL>"); to check.

string sInsertSql = "INSERT INTO rac.HisAtual (UserInc)values(" + ew_AdjustSql(CurrentUserName())

  • ") WHERE IdOcr="+IdOcr.CurrentValue;
    ew_End(sInsertSql); //*** add this line to debug and execute the SQL in your Database Manager to verify

Post Reply