I am trying to run a stored proc from this function. When I run it thorugh the debugger I can see that myReader.HasRows = true and myReader.FieldCount =14.
But the control does not go in the loop while (myReader.Read()) where I am trying to read Version field returned by the stored proc.
Pls check me code and suggest correction. Thank You.
private static int Get_CaseInfo(string CaseNum)
{
int Ver = 0;
String myConn = ConfigurationManager.ConnectionStrings["DBConnectionString"].ToString();
SqlConnection conn = new SqlConnection(myConn);
SqlCommand cmd = new SqlCommand();
cmd.CommandType = System.Data.CommandType.Text;
SqlDataReader myReader = null;
String stmt1 = "EXEC [REPORTS].[CaseInfoByCaseNo_Get] @CaseNo = '" + CaseNum + "'";
cmd.CommandText = stmt1;
cmd.Connection = conn;
try
{
conn.Open();
myReader = cmd.ExecuteReader();
while (myReader.Read())
{
Ver = (int)myReader["Version"];
}
}
catch (Exception)
{
throw;
}
return Ver;
}
View Complete Post