Try this:
private static void GetInvoice()
{
try
{
using (SqlConnection con = new SqlConnection(Class_Connection.ETConnection))
{
con.Open();
using (SqlCommand cmd = con.CreateCommand())
{
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "GetPurchaseInvNo";
SqlDataReader dr = cmd.ExecuteReader();
dr.Read();
if (dr.HasRows)
{
TextBox1.Text= dr[0].ToString();
}
dr.Close();
}
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}