please people i need your help here. I am learning how to develop a hospital diagnostic software. problem is how to match user input sentence with what i have in the database, talking about symptoms matching. plaese help me to achieve this. here is my code:
protected void Button1_Click(object sender, EventArgs e)
{
using (DataTable symptoms_dt = LookupUser(User_symptoms.Text))
{
if (dt.Rows.Count == 0)
{
MessageBox.Show("Error in processing");
return;
}
else
{
string db_symptoms = Convert.ToString(symptoms_dt.Rows[0]["Symptoms"]);
//MY PROBLEM
//below i want to match the user symptoms Text with dbs symptoms that i retrieved
// to get the one that is, if not exactly; close to it,
// for instance comparing "headache and dizziness" with "headache and tiredness",
// "stomach pain,headache, heartburn",
// you find out that the one that nearly match are the first two
if (String.Compare(db_symptoms, User_symptoms.Text) == 0)
{
//then i could output...
}
else
{MessageBox.Show("No match for symptom");
return;
}
}
}
}
}
private static DataTable LookupUser(string User_symptoms.Text)
{
string connStr = ConfigurationManager.ConnectionStrings["SymptomsConnectionString1"].ConnectionString;
//MY PROBLEM
// the line below is problem. because i want select things that are like the content of textbox input
// from dbs
const string query = "Select Symptoms From Symptable Where Symptoms LIKE '%User_symptoms.Text'";
DataTable result = new DataTable();
using (SqlConnection conn = new SqlConnection(connStr))
{
conn.Open();
using (SqlCommand cmd = new SqlCommand(query, conn))
{
cmd.Parameters.Add("@Symptoms", SqlDbType.VarChar).Value = User_symptoms.Text;
using (SqlDataReader dr = cmd.ExecuteReader())
{
result.Load(dr);
}
}
}
return result;
}
}