Ron Aricha

Ron Aricha

  • 2.1k
  • 51
  • 1.2k

Add string to DataSet

Dec 8 2018 5:02 AM
Hello,
I want to add to the DataSet in the highlighted line a variable of type string
How to do this?
private void fillExamList()
{
string selectExamination = "SELECT ExamType.ExamTypeString, FullName, ExamDate, ExamCode FROM ExamType INNER JOIN Examination ON ExamType.ExamType = Examination.ExamType WHERE PatientID = " + txtSearchID.Text + "";
SqlDataAdapter da = new SqlDataAdapter(selectExamination, conn);
DataSet ds = new DataSet();
try
{
conn.Open();
da.Fill(ds);
ds.Tables[0].Columns.Add("ExamList", typeof(string), "FullName + ', ' + ExamTypeString");
ddlExamList.DataValueField = "ExamCode";
ddlExamList.DataTextField = "ExamList";
ddlExamList.DataSource = ds;
ddlExamList.DataBind();
ddlExamList.Items.Insert(0, new ListItem("Select...", "0"));
}
catch (Exception ex)
{
ErrorHandling(ex.ToString());
}
finally
{
conn.Close();
}
}

Answers (4)