Avoid Duplicate Records

Posted by Priti2010 under ASP.NET on 8/2/2011 | Points: 10 | Views : 4625 | Status : [Member] | Replies : 11
can any one help me out how can i avoid the duplicate records not to save in the gridview

Thanks & Regards
Priti



Responses

Posted by: A4u_6178 on: 8/2/2011 [Member] Starter | Points: 25

Up
0
Down
Hi,
try below link it has sample application..
http://usingaspdotnet.blogspot.com/2011/03/avoid-insertion-of-duplicate-using.html
I hope its helpful,

Thanks & Regards,

Priti2010, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Priti2010 on: 8/2/2011 [Member] Starter | Points: 25

Up
0
Down
site which have provided is blocked in my pc

Thanks & Regards
Priti

Priti2010, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: A4u_6178 on: 8/2/2011 [Member] Starter | Points: 25

Up
0
Down
There was an article in link which i provided before..
pls find attachment with this post.(a zipped text file)

 Download source file

Thanks & Regards,

Priti2010, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Umakant151 on: 8/2/2011 [Member] Starter | Points: 25

Up
0
Down
to eliminate duplicate records from the table the SELECT command with DISTINCT clause is used.

Syntax:
SELECT DISTINCT columnname1, columnname2
FROM tablename;


Umakant

Priti2010, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Priti2010 on: 8/2/2011 [Member] Starter | Points: 25

Up
0
Down
i want to make a procedure to check the duplicate records if already exists show an error and if not save the records and also while update also

Thanks & Regards
Priti

Priti2010, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Priti2010 on: 8/2/2011 [Member] Starter | Points: 25

Up
0
Down
thanx for the help but can u tell me how can i used this procedure in my code as i m new to programming
CREATE PROCEDURE sp_ServiceRcds
-- Add the parameters for the stored procedure here
(@Service_Name nchar(100),
@Otputs nchar(50) output)
AS
BEGIN
SET NOCOUNT ON;
DECLARE @result nchar(50)
IF EXISTS (select * from tbl_Service where Service_Name = @Service_Name)
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET @result = 'Records Already exits'
END
ELSE
BEGIN
INSERT into tbl_Service(Service_Name) values(@Service_Name)
-- Insert statements for procedure here
SET @result ='Records Added'
END
END

Thanks & Regards
Priti

Priti2010, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Chvrsri on: 8/2/2011 [Member] [Moderator] [MVP] Silver | Points: 25

Up
0
Down
kindly check this following condition in your page load

protected void Page_Load(object sender, EventArgs e)

{
if (!IsPostBack)
{
// Do your Operations
}
}



Thanks,
Radha Srikanth

Priti2010, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Hmanjarawala on: 8/3/2011 [Member] Bronze | Points: 25

Up
0
Down
Hi Priti2010 write down code below:
SqlConnection con = new SqlConnection("<ur-connection-string>");
SqlCommand com = new SqlCommand("sp_ServiceRcds", con);

com.Parameters.Add("@Service_Name", SqlDbType.NChar);
com.Parameters(0).Length=100;
com.Parameters(0).Value = <ur-param-value>;

com.Parameters.Add("@output", SqlDbType.NChar);
com.Parameters(1).Length=50;
com.Parameters(1).Direction = ParameterDirection.Output;

con.Open();
com.CommandType = CommandType.StoreProcedure;
com.ExecuteNonQuery();

this way you can execute store procedure from your application.

Hope this will help you.

Himanshu Manjarawala
Sr. Software Engineer@AutomationAnywhere
http://fieredotnet.wordpress.com/

Priti2010, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Madhu.b.rokkam on: 8/3/2011 [Member] [MVP] Bronze | Points: 25

Up
0
Down
Hi,

Read the grid datasource to a dataTable variable and using LINQ filter the distinct rows and update.


Thanks and Regards
Madhu

Priti2010, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Priti2010 on: 8/5/2011 [Member] Starter | Points: 25

Up
0
Down
thanx for the help

Thanks & Regards
Priti

Priti2010, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: perfectchourasia-9163 on: 4/3/2012 [Member] Starter | Points: 25

Up
0
Down
http://sandeep-chourasia.blogspot.in/2011/12/delete-duplicate-data.html

ER sandeep chourasia
sandeepchrs@yahoo.com (on facebook)
http://www.aspnetcodes.com/

Priti2010, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response