id不是从一个表传递到另一个表
问题描述:
if (RadioNEW.Checked == true)
{
SqlConnection sc = new SqlConnection(System.Web.Configuration.WebConfigurationManager.ConnectionStrings["hospitalmanagementdb"].ToString());
SqlCommand cmd = new SqlCommand("insert into patient values('" + txtFirstnm.Text + "','" + txtLastnm.Text + "','" + RadioMF.Text + "','" + txtAge.Text + "','" + txtContact.Text + "','" + txtEmail.Text + "','" + txtAddress.Text + "')", sc);
cmd.Connection = sc;
sc.Open();
cmd.ExecuteNonQuery();
sc.Close();
}
else
{
SqlConnection sc1 = new SqlConnection(System.Web.Configuration.WebConfigurationManager.ConnectionStrings["hospitalmanagementdb"].ToString());
sc1.Open();
SqlCommand cm = new SqlCommand("insert into appointment values((select max(patient_id) from patient),'" + dropQueue.SelectedValue.ToString() + "','" + System.DateTime.Today.Date.ToString() + "','treated')", sc1);
cm.Connection = sc1;
cm.ExecuteNonQuery();
sc1.Close();
}
if (RadioNEW.Checked == true)
{
SqlConnection sc = new SqlConnection(System.Web.Configuration.WebConfigurationManager.ConnectionStrings["hospitalmanagementdb"].ToString());
SqlCommand cmd = new SqlCommand("insert into patient values('" + txtFirstnm.Text + "','" + txtLastnm.Text + "','" + RadioMF.Text + "','" + txtAge.Text + "','" + txtContact.Text + "','" + txtEmail.Text + "','" + txtAddress.Text + "')", sc);
cmd.Connection = sc;
sc.Open();
cmd.ExecuteNonQuery();
sc.Close();
}
else
{
SqlConnection sc1 = new SqlConnection(System.Web.Configuration.WebConfigurationManager.ConnectionStrings["hospitalmanagementdb"].ToString());
sc1.Open();
SqlCommand cm = new SqlCommand("insert into appointment values((select max(patient_id) from patient),'" + dropQueue.SelectedValue.ToString() + "','" + System.DateTime.Today.Date.ToString() + "','treated')", sc1);
cm.Connection = sc1;
cm.ExecuteNonQuery();
sc1.Close();
}
患者表的ID未通过预约表
id of patient table is not passing in appointment table
答