protected void btnAddQueue_Click(object sender, EventArgs e)
{
string query = string.Empty;
if (RadioNEW.Checked)
{
query = "insert into patient values('" + txtFirstnm.Text + "','" + txtLastnm.Text + "','" + RadioMF.Text + "','" + txtAge.Text + "','" + txtContact.Text + "','" + txtEmail.Text + "','" + txtAddress.Text + "')";
}
else
{
query = "insert into appointment values((IDENT_CURRENT('patient')),'" + dropQueue.SelectedValue.ToString() + "','" + System.DateTime.Today.Date.ToString() + "','treated')"
}
using (SqlConnection con = new SqlConnection(System.Web.Configuration.WebConfigurationManager.ConnectionStrings["hospitalmanagementdb"].ToString()))
{
using(SqlCommand cmd = new SqlCommand(query, conn))
{
con.Open();
cmd.ExecuteNonQuery();
con.Close();
}
}
}
It's highly recomended that you use storeprocedure in order to use IDENT_CURRENT() inside it. More info about IDENT_CURRENT(TABLE)
here[
^].
Hope it helps.