I have a problem when I executed Select command in C# using ExecuteNonQuery() method; It always return -1; This means that no record returned by the selected statement, doesn’t it?
But when i open sql managment studio and run the same select statement; I found that it returned rows.
Please help me!
You shouldn’t execute a
SELECT with an ExecuteNonQuery(). It is called ExecuteNonQuery because you want something to execute that is not a query. ASELECTis a query. You want to ExecuteReader. If you want to do anUPDATEorDELETE, then you can do anExecuteNonQuery()and that will show how many rows were affected.