Why executenonquery returns negative
What for a problem? It's a documented behavior, see DbCommand. For all other types of statements, the return value is The database used is the azure version of ms sql server. Moreover, the return value obtained by the program before the problem is always greater than or equal to 0, It is not clear what caused the occasional return of negative numbers recently.
In my experience, System. The row count value returned should be the same whether the SqlCommand. ExecuteNonQuery is invoked directly or via the base type System. ExecuteNonQuery base type as in your case. Are you reusing the same connection for different queries? Add your solution here. OK Paste as. Treat my content as plain text, not as HTML. Existing Members Sign in to your account. This email is in use. Do you need your password? Submit your solution!
When answering a question please: Read the question carefully. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question. Let's work to help developers, not make them feel stupid. Related Questions. ExecuteNonQuery returning ExecuteNonQuery always return ExecuteNonQuery always return 0 in stored procedure. Why executeNonQuery returns 1 for insert and -1 for stored procedure and trigger.
Sqlcommand executenonquery throws exception system. The connection's current state is closed. Layout: fixed fluid.
Web01 2. Strip HTML. Encode HTML. Paste as-is. I started out using transactions, but then switched to a non transaction Insert statement to investigate this problem.
The row inserted has one column which is a foriegn key to another table. Everything appears to be in order. Here is the code:. Generic; using System. Linq; using System. Web; using System. UI; using System. WebControls; using System. SqlClient; using System. Configuration; using System. Clear ; cmd. AddWithValue " InvoiceKey", 27 ; cmd. AddWithValue " JobNum", 1 ; cmd. AddWithValue " SubTotal", BigInt ; cmd. Parameters[" JobKey"].
0コメント