ExecuteNonQuery doesn't return results

后端 未结 9 1888
迷失自我
迷失自我 2020-11-28 10:46

This is my (rough) code (DAL):

int i;
// Some other declarations

SqlCommand myCmdObject = new SqlCommand(\"some query\");

conn.open();
i = myCmdObject.Exec         


        
9条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-28 11:22

    The ExecuteNonQuery method is used for SQL statements that are not queries, such as INSERT, UPDATE, ... You want to use ExecuteScalar or ExecuteReader if you expect your statement to return results (i.e. a query).

提交回复
热议问题