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
Ashish Khandelwal
NA
8
9.1k
Ado.net dataset no primary key violation
Sep 18 2011 1:22 AM
I am using dataadapter to fill dataset from a table with primary key. When I made changes in dataset for duplicate value in that column it doesn't display primary key violation. Also it accept changes with dataset's accept change command. My question is why it doesn't display primary key violation . Whether dataset doesn't keep primary key from its source table? and need to explictly make it primary key. If dataset doesn't accept primary key then why dataadapter shows its inability to delete records if fill data from table without primary key.
string sqlcommand = "select * from itemmaster";//itemaster contains id field which is primary key//
SqlConnection
cn
=
new
SqlConnection
(
connstring
);
cn
.
Open
();
SqlCommand
cmd
=
new
SqlCommand
(
sqlcommand
,
cn
);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet(); da.Fill(ds);
ds.Tables[0].Rows[4]["ID"] = "2"; // value 2 already exists in another row
Reply
Answers (
2
)
Difference language
How can we check disabled user in active directory?