Click here to Skip to main content
15,915,164 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
I'm not sure why auto-generator make TableAdapter with 'insert' and 'select' command by TableAdapter configuration wizard, if they have any primary keys on VisualStudio2010.

The below code is generated from the wizard.

InsertCommand = INSERT INTO [Table] ([UserID], [Password]) VALUES (@UserID, @Password); SELECT UserID, Password FROM Table WHERE (UserID = @UserID)


I heard it caused concurrency violation Exception if 'select' block is manually removed.

So is it to adjust between DB and TableAdapter?

Any comment is welcome.

Thank you in advance.
Posted
Updated 25-Aug-12 2:00am
v4

The TableAdapter classes are for people too dumb to write their own code. They have almost no use in real world code, they break every rule of data abstraction. Write your own data layer.
 
Share this answer
 
Comments
axt_star 25-Aug-12 9:32am    
It's severe opinion. I have no problem with source code.
It's only my curious. So I have no code and only I tried that by VisualStudio.
Anyway, thank you telling me interested matter.
Hi,

Specially when people ask me for data Interaction scenario, i prefer SQLHelper class and Stored Procedures. If you would like to follow N-Tier architecture then you can separate you Data Access Layer.

So, i suggest you to create Stored procedure for all your database interactions. Create Transactions if required in the stored procedure. Call your SP from Data Access Layer and Bind it with the real Class object.

Truly speaking i have never used TableAdapter in my projects.

Please refer this : SQL Helper Class[^]

SQL helper class will reduce your work. you can improve that class as per your requirement(but i don't think you need at this stage)

Thanks
-Amit Gajjar.
 
Share this answer
 
Comments
axt_star 27-Aug-12 7:15am    
Thank you for telling me nice advice.
AmitGajjar 27-Aug-12 8:14am    
i am very glad as my reply helps you :)

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