Add a catch or finally block:
private void txtCountryCode_Enter(object sender, EventArgs e)
{
try
{
if (txtVehClass.Text.Trim() == string.Empty)
return;
string strQry = string.Empty;
strQry = "Select * from VehClass where upper(code)='" + txtVehClass.Text.Trim().ToUpper() + "' and isnull(intstatus,0)=0";
if (dsGrid != null && dsGrid.Tables.Count > 0 && dsGrid.Tables[0].Rows.Count > 0)
{
txtVehClass.Tag = dsGrid.Tables[0].Rows[0]["Intcode"].ToString();
txtVehClass.Text = dsGrid.Tables[0].Rows[0]["code"].ToString();
txtVehClassName.Text = dsGrid.Tables[0].Rows[0]["NameArb"].ToString();
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
Do note that you are also missing an open curly bracket after the
if
statement - indentation will not make it execute all three statements without it! (I added it here so you can see what I mean)