What is wrong with this code? From what I have read it should work just fine. According to this post it should work but it doesn't. thread732-448638
My code can't see the
object in the catch portion.
I am getting this error when I build the object.
The type or namespace name 'oConn' could not be found (are you missing a using directive or an assembly reference?)
My code can't see the
Code:
oConn
I am getting this error when I build the object.
The type or namespace name 'oConn' could not be found (are you missing a using directive or an assembly reference?)
Code:
try
{
SqlConnection oConn = new SqlConnection(strConnStr);
oConn.Open();
SqlCommand oCmd = new SqlCommand(sqlCmd, oConn);
oCmd.CommandText = sqlCmd;
oCmd.CommandType = CommandType.Text;
...
}
catch (Exception e)
{
oConn.Close();
}