here is what I have
protected void Wizard1_FinishButtonClick(object sender, WizardNavigationEventArgs e)
{
Page.Validate();
ID = txtEmpID.Text;
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["no_callConnectionString1"].ConnectionString);
SqlCommand oldcmd = new SqlCommand("SELECT * from dbo.myTable WHERE [My ID] = '" + ID + "'", conn);
oldcmd.CommandType = CommandType.Text;
SqlDataAdapter da = new SqlDataAdapter(oldcmd);
DataTable dt = new DataTable();
da.Fill(dt);
if (Page.IsValid && dt.Rows.Count < 1)
{
lblExists.Visible = true;
lblExists.Text = "Please review your information before submitting. If you need to make a change please choose 'previous', otherwise select 'next' to continue.";
SqlCommand newcmd = new SqlCommand("Insert Into registration ([My ID],[First Name],[Last Name],[Department]) Values (@MyID,@FName,@LName,@Department)", conn);
newcmd.CommandType = CommandType.Text;
newcmd.Parameters.AddWithValue("@MyID", ID);
newcmd.Parameters.AddWithValue("@FName", txtFname.Text);
newcmd.Parameters.AddWithValue("@LName", txtLname.Text);
newcmd.Parameters.AddWithValue("@Department", Department);
conn.Open();
newcmd.ExecuteNonQuery();
}
}
What it does is reports the page submitted even if it spots the primary key there is no duplicate error? any ideas?
Loading
Kunal VaishyaPosted May 8, 2012, 12:44 AM
check first primary key already exist or not
dear as per Jignesh Trivedi please clarify the bug which you are getting now
Jignesh TrivediPosted May 8, 2012, 12:09 AM
your code is correct. are u getting any error?
can u please provide more info.
thx.