我对 C# 有点陌生,不知道我做错了什么。试图找到解决方案但失败了。提前致谢。
当我不使用参数“select * from Καρτέλα_Ασθενή”时;表单将填充来自读者的值。表单没有带来值,换句话说,看起来 select 命令不起作用。
OleDbCommand cmd = new OleDbCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = "select * from Καρτέλα_Ασθενή where Κωδ_Ασθενή = @Κωδ_Ασθενή";
cmd.Parameters.AddWithValue("@Κωδ_Ασθενή", MyGlobals.Patient_code);
cmd.Connection = accessdb;
accessdb.Open();
OleDbDataReader dr = cmd.ExecuteReader();
if (dr.Read())
{
while (dr.Read())
{
txt_patient_code.Text = dr["Κωδ_Ασθενή"].ToString();
txt_Surname.Text = dr["Επώνυμο"].ToString();
txt_Name.Text = dr["Όνομα"].ToString();
txt_date.Text = Convert.ToDateTime(dr["Ημερομηνία_Γέννησης"]).ToShortDateString();
txt_address.Text = dr["Διεύθυνση"].ToString();
txt_area.Text = dr["Περιοχή"].ToString();
txt_phone.Text = dr["Τηλ"].ToString();
txt_fax.Text = dr["Φαξ"].ToString();
txt_insurance.Text = dr["Ασφάλεια"].ToString();
txt_comments.Text = dr["Παρατηρήσεις"].ToString();
txt_history.Text = dr["Ιστορικό"].ToString();
txt_alergies.Text = dr["Αλλεργίες"].ToString();
txt_email.Text = dr["e-mail"].ToString();
}
}
dr.Close();
accessdb.Close();