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
Yogesh Vedpathak
675
1.4k
191.9k
Exception Violation of PRIMARY KEY constraint 'PK_tbl_LineSt
Apr 24 2018 7:36 AM
Violation of PRIMARY KEY constraint 'PK_tbl_LineStatus1'. Cannot insert duplicate key in object 'dbo.tbl_LineStatus1'.
The statement has been terminated.
This is my Piece of code
using
(sqlTrans = sqlCon.BeginTransaction(
"Trans"
))
{
try
{
string
query =
"Insert into tbl_LineStatus1(TransID,Date,LineID,UserID) Values('"
+ TransID +
"','"
+ DateTime.Now.ToString(
"dd/MM/yyyy"
) +
"','"
+ ddl_linenumber.SelectedItem.Value.ToString() +
"','"
+ username.ToString() +
"')"
;
sqlCmd =
new
SqlCommand(query, sqlCon);
sqlCmd.Transaction = sqlTrans;
sqlCmd.ExecuteNonQuery();
}
catch
(Exception ex)
{
}
Reply
Answers (
3
)
JSON.parse(string)
.Net using hindi Font