private int GetId(int userId, int companyId){
string query = String.Format("SELECT Id FROM MyTable WHERE UserId = {0} AND CompanyId = {1}", userId, companyId);
return _db.ExecuteSqlCommand(query);
}
I can run the query via Microsoft's SQL Management Studio and it returns 15. Every time I execute it within the code it returns -1.
MSDN API States:
Return Value
Type: System.Int32
The result returned by the database after executing the command.
The description is very vaugue, and I think how I am using it should be working. How can I manipulate the query to return 15, or is that not possible? If not, does anyone have any recommendations?