static string conn = System.Configuration.ConfigurationManager.ConnectionStrings["MyConnStr"].ConnectionString;
private void btnSearch_Click(object sender, EventArgs e)
{
if (ddlFilter.Text == "SELECT")
{
MessageBox.Show("Please select a value from the drop down list");
}
else
{
try
{
initDebt.CommandType = CommandType.StoredProcedure;
initDebt.CommandText = "MyStoredProc";
initDebt.Parameters.Clear();
initDebt.Parameters.Add("@Filter", SqlDbType.VarChar, 20).Value = ddlFilter.Text;
initDebt.Parameters.Add("@SearchStr", SqlDbType.VarChar, 40).Value = txtSearchStr.Text;
da.Fill(dt);
txtSS.Text = dt.Rows[0]["SS_Num"].ToString();
txtLName.Text = dt.Rows[0]["last_Name"].ToString();
txtFName.Text = dt.Rows[0]["first_name"].ToString();
txtAgt.Text = dt.Rows[0]["agent_num"].ToString();
txtStore.Text = dt.Rows[0]["agent_name"].ToString();
}
catch (Exception ex)
{
MessageBox.Show("There are no records that match your search criteria. "+ ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}