sqlResult = this.Database.ExecuteSqlCommand(sqlCommand,new SqlParameter(" @InSTALLATION",installationId),new SqlParameter(" @ OBJNAM",objName)); if(sqlResult< = 0){sqlResult = 0; [英] sqlResult = this.Database.ExecuteSqlCommand(sqlCommand, new SqlParameter("@INSTALLATION", installationId), new SqlParameter("@OBJNAM", objName)); if (sqlResult <= 0) { sqlResult = 0;
问题描述
executionqlcommand方法返回值
executesqlcommand methods returns values
有人有一个图表,表明返回值对于执行的命令的含义是什么 方法?
Do someone have a chart of what the return values mean for the executesqlcommand method?
-1是什么意思?
0是什么意思?
这是我在c夏普代码中所做的逻辑。我需要在返回值时更新或插入记录库。
This is the logic I am doing in the c Sharp code. I need to update or insert record base upon return value.
sqlResult = this.Database.ExecuteSqlCommand(sqlCommand, new SqlParameter("@INSTALLATION", installationId), new SqlParameter("@OBJNAM", objName));
if (sqlResult <= 0)
{
//Insert record into database
}
else
{
//Update record into database
}
pianoboyCoder
pianoboyCoder
推荐答案
如果要插入数据,1表示添加了一行,超过1表示添加了多行。同样适用于更新命令。
Well if you are inserting data, 1 means one row added, more than 1 means more than one rows added. Same goes for an update command.
对于0,没有添加或更新行。
For 0, no rows added or updated.
对于-1通常这是有某种问题涉及执行的内容,例如INSERT,UPDATE等。
For -1 usually this is there was some sort of problem involved with what was executed e.g. INSERT, UPDATE etc.
这篇关于sqlResult = this.Database.ExecuteSqlCommand(sqlCommand,new SqlParameter(" @InSTALLATION",installationId),new SqlParameter(" @ OBJNAM",objName)); if(sqlResult< = 0){sqlResult = 0;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!