TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Obadiah Williams
NA
4
5.9k
Primary key exist check not functioning
May 4 2012 8:39 AM
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?
Reply
Answers (
2
)
app.config file path with space
Finding pixel value using Glyph recognition