Get data from (dr.Reader()) {}
try
{
con.Open();
SqlCommand cmd = new SqlCommand("Proc_Emp", con);
SqlDataAdapter sda = new SqlDataAdapter(cmd);
cmd.Parameters.Add("@PNo", SqlDbType.VarChar, 50).Value = comboBox1.Text.Trim();
sda.SelectCommand.CommandType = CommandType.StoredProcedure;
DataTable dt = new DataTable();
sda.Fill(dt);
string num = dt.Rows[0][0].ToString();
SqlCommand cmd1 = new SqlCommand("select Name from tbl_2 where records='" +
comboBox1.Text + "'", con);
SqlDataReader dr = cmd.ExecuteReader();
if (dr.Read())
{
string A = dr["Name"].ToString();
}
string max = A +num;
con.Close();
}
catch (SqlException ex)
{
MessageBox.Show("Error: " + ex);
}
finally
{
string r= max;
textBox1.Text = r;
}
2020-06-04