CODE
private void FillClientCodes()
{
//Gets a list of client codes from EMR Database
lvClientCodes.Visible = true;
lvClientCodes.Items.Clear();
SqlConnection con = new SqlConnection(constring);
SqlDataReader rdr = null;
try
{
con.Open();
SqlCommand cmd = new SqlCommand("EHR_GetClientCodes", con);
cmd.CommandType = CommandType.StoredProcedure;
rdr = (SqlDataReader)cmd.ExecuteReader();
ListViewItem itmX;
while (rdr.Read())
{
itmX = new ListViewItem();
itmX.Text = rdr.GetValue(0).ToString();
for (int i = 1; i < rdr.FieldCount; i++)
{
itmX.SubItems.Add(rdr.GetValue(i).ToString());
}
lvClientCodes.Items.Add(itmX);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
finally
{
if (con != null)
{
con.Close();
}
if (rdr != null)
{
rdr.Close();
}
}
{
//Gets a list of client codes from EMR Database
lvClientCodes.Visible = true;
lvClientCodes.Items.Clear();
SqlConnection con = new SqlConnection(constring);
SqlDataReader rdr = null;
try
{
con.Open();
SqlCommand cmd = new SqlCommand("EHR_GetClientCodes", con);
cmd.CommandType = CommandType.StoredProcedure;
rdr = (SqlDataReader)cmd.ExecuteReader();
ListViewItem itmX;
while (rdr.Read())
{
itmX = new ListViewItem();
itmX.Text = rdr.GetValue(0).ToString();
for (int i = 1; i < rdr.FieldCount; i++)
{
itmX.SubItems.Add(rdr.GetValue(i).ToString());
}
lvClientCodes.Items.Add(itmX);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
finally
{
if (con != null)
{
con.Close();
}
if (rdr != null)
{
rdr.Close();
}
}