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
Israel
NA
1.3k
204.4k
Preventing duplicated records
Aug 24 2015 7:45 AM
Hi!
I wrote this codes for saving my records. But I dont want to see later my records repeated (or duplicated). How can I do to prevent it. When the same datas is already exist its should inform and refus. Save only when its doesnt exist in the database:
...
public Form1()
{
InitializeComponent();
}
OleDbConnection conn = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\WindowsFormsApplication1\App_data\test.mdb;Persist Security Info=False");
OleDbCommand comm;
string connstr = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\WindowsFormsApplication1\App_data\test.mdb;Persist Security Info=False";
private void button1_Click(object sender, EventArgs e)
{
conn = new OleDbConnection(connstr);
comm = new OleDbCommand();
conn.Open();
OleDbParameter name = new OleDbParameter("@name", SqlDbType.Date);
OleDbParameter fonction = new OleDbParameter("@fonction", SqlDbType.Date);
comm.Parameters.Add(name);
comm.Parameters.Add(fonction);
name.Value = textBox1.Text;
fonction.Value = textBox2.Text;
comm.Connection = conn;
comm.CommandText = "select count(*) from Not_duplicated_datas where name = @name";
int count = (int)comm.ExecuteScalar();
comm.ExecuteNonQuery();
conn.Close();
}
Reply
Answers (
1
)
creating dynamic label in array and retriving data from data
how to do paging in datalist control