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
jeff lee
NA
11
1.2k
stop duplicate record in database
Jun 2 2019 6:14 AM
I need to stop duplicate records in my sql table and if data exists how can i show message says already exists this is my code below :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Windows.Forms;
using System.Data;
using System.Data.SqlClient;
namespace cap
{
public partial class WebForm1 : System.Web.UI.Page
{
SqlConnection con;
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click1(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(@"Data Source=DESKTOP-6I0G8AT;Initial Catalog=cap;Integrated Security=True");
con.Open();
string store = "INSERT INTO Customer (Cust_Name,Cust_Username,Cust_Email,Cust_Contact,Cust_Password ) VALUES (@Cust_Name,@Cust_Username,@Cust_Email,@Cust_Contact,@Cust_Password)";
SqlCommand cmd = new SqlCommand(store,con);
cmd.Parameters.AddWithValue("@Cust_NAME", txtfirstname.Text + " " + txtlastname.Text);
cmd.Parameters.AddWithValue("@Cust_Username", txtusername.Text);
cmd.Parameters.AddWithValue("@Cust_Email", txtemail.Text);
cmd.Parameters.AddWithValue("@Cust_Contact", txtcontact.Text);
cmd.Parameters.AddWithValue("@Cust_Password", txtpassword.Text);
cmd.ExecuteNonQuery();
con.Close();
}
}
}
Reply
Answers (
6
)
I am getting timeout error in my code while retrieve data from database
Serialization Assigning Value to Properties getting Error