C# SQL SELECT Statement
- by Feren6
I have the following code:
SqlCommand cmd2 = new SqlCommand("SELECT ClaimId FROM tblPayment WHERE PaymentId = " + PaymentID.ToString(), mvarDBConn);
SqlDataReader reader = cmd2.ExecuteReader();
reader.Read();
Int32 ClaimId = reader.GetInt32(0);
reader.Close();
If I run the SELECT statement in SQL it returns the number fine, but when I use ExecuteReader all it returns is 0. I've tried multiple methods including ExecuteScalar, ExecuteNonQuery, reader.GetString then casting that to an int, etc.
What am I missing? Thanks.