Click here to Skip to main content
15,888,610 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
C#
SqlConnection con = Tools.Baglanti; 
            SqlDataAdapter adapt = new SqlDataAdapter("WITH CTE (Name,SurName,Tckn,Email, DuplicateCount) AS ( SELECT Name, SurName, Tckn, Email, ROW_NUMBER() OVER(PARTITION BY Name, SurName, Tckn, Email ORDER BY Id) AS DuplicateCount FROM Employees ) DELETE FROM CTE WHERE DuplicateCount > 1", con);


What I have tried:

there is a problem with my code that I cant find where it is ?
command text is working on sql but not in c#
Posted
Updated 11-Sep-16 20:33pm
v2
Comments
David_Wimbley 11-Sep-16 19:11pm    
You need to post your error/exception you are getting. Saying it isn't working isn't helpful for you or those trying to help you.

The only tips you're probably going to get are to use breakpoints/your debugger to step through your code and figure out what is happening.
[no name] 11-Sep-16 20:52pm    
Considering that we do not have your database, your data, your code or see your screen, what is it exactly that you would expect us to do with these 2 lines of code? Especially when you didn't tell us what the "problem" was. We are not mind readers.

1 solution

Such of code should be writen as a stored procedure[^]. Then you'll be able to call it from client side. Use SqlCommand.ExecuteNonQuery Method (System.Data.SqlClient)[^] for CRUD[^] operation.

For further details, please see:
Walkthrough: Creating a simple data application by using ADO.NET[^]
How to call stored procedure[^]
How to: Execute a Stored Procedure that Returns Rows[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900