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
Ravishankar Velladurai
NA
7.9k
1.4m
duplicate record is created in database on page reload
Mar 30 2020 3:16 AM
How to Prevent or Avoid Duplicate Record Insertion on Refresh(F5) Click in Browser in ASP.Net ?
using
System;
using
System.Text;
using
System.Collections.Generic;
using
System.Linq;
using
System.Web;
using
System.Web.UI;
using
System.Web.UI.WebControls;
using
System.Data.SqlClient;
using
System.Data;
namespace
Student_Management
{
public
partial
class
Student_Registration : System.Web.UI.Page
{
SqlConnection con =
new
SqlConnection(@
"Data Source=192.168.31.222;Initial Catalog=Student_Database;Integrated Security=True;MultipleActiveResultSets=true;"
);
protected
void
Page_Load(object sender, EventArgs e)
{
if
(con.State == ConnectionState.Open)
{
con.Close();
// Response.Redirect(Request.Url.ToString(), false);
}
con.Open();
}
protected
void
Button2_Click(object sender, EventArgs e)
{
if
(TextBox1.Text == String.Empty)
{
Label1.Text =
"Fill Registration Number"
;
}
else
if
(TextBox2.Text == String.Empty)
{
Label1.Text =
"Fill Name"
;
}
else
if
(TextBox3.Text == String.Empty)
{
Label1.Text =
"Fill Qualification"
;
}
else
if
(TextBox4.Text == String.Empty)
{
Label1.Text =
"Fill Location"
;
}
else
if
(TextBox5.Text == String.Empty)
{
Label1.Text =
"Fill Phone"
;
}
else
if
(TextBox6.Text == String.Empty)
{
Label1.Text =
"Fill Email ID"
;
}
else
{
SqlCommand cmd = con.CreateCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText =
"insert into Student_Details values('"
+ TextBox1.Text +
"','"
+ TextBox2.Text +
"','"
+ TextBox3.Text +
"','"
+ TextBox4.Text +
"','"
+ TextBox5.Text +
"','"
+ TextBox6.Text +
"')"
;
cmd.ExecuteNonQuery();
TextBox1.Text =
""
;
TextBox2.Text =
""
;
TextBox3.Text =
""
;
TextBox4.Text =
""
;
TextBox5.Text =
""
;
TextBox6.Text =
""
;
Response.Write(
"<script>alert('INSERT NEW STUDENT DATA SUCCESS')</script>"
);
Label1.Visible =
false
;
con.Close();
}
}
}
}
Reply
Answers (
2
)
itext Sharp (Needs to Store Some properties To Sql server)
how to install missed packages from Packages offline Setting