Sorry if this was asked before. I searched for an hour and did not find the exact problem I was facing.
I use SMO to run some queries against SQL Server because I read this, it can handle statements GO, not System.Data.SqlClient.
I execute this query:
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
UPDATE Program
SET ENABLED = '1'
WHERE Program_ID = '64' AND Program_Name = 'DoesSomething'
I grab the "affected lines":
int numberOfRows = db.ConnectionContext.ExecuteNonQuery(s.Query);
The problem I am facing is that it returns -1 every time. I check the database behind the scenes, and it updates the value every time, and when I manually run the query in SSMS, I get a confirmation (1 line).
, . GO, 1 -1.
/, , GO, SET ANSI_NULLS ON SET QUOTED_IDENTIFIER ON , ( - , /), - ? , - , , ?
... , ExecuteNonQuery . , , , , ( 1).