Tech
Forums
Jobs
Books
Events
Videos
Conference
Annual Conference
Bcrypt
Ai Conference
Live
More
Interviews
Certification
Training
Career
Members
News
Blogs
Contribute
An Article
A Blog
A Video
An Ebook
An Interview Question
Register
Login
1
Answer
Foreign key data deleting error in ADO.NET Application
Ask a question
Ask a question
Upload Source Code:
Select only zip and rar file.
Bineesh VP
10y
1.4k
1
Reply
Sir, I am in the midst of a Data Deleting problem as it a foreign key.
Below the table where getting problem when delete data:-
tbl-Class tbl_Division
------------ ----------------
classId divisionId
className divisionName
noOfSeats classId
I cannot delete data from tbl_Class
as I getting the error in below :-
Form.cs code:-
SP Class
code :-
public int
ClassDelete(
classInfo
infoClass)
{
try
{
if
(sqlCon.State ==
ConnectionState
.Closed)
{
sqlCon.Open();
}
SqlCommand
cmd =
new
SqlCommand
(
"ClassDelete"
, sqlCon);
cmd.CommandType =
CommandType
.StoredProcedure;
cmd.Parameters.Add(
"classId"
,
SqlDbType
.Int).Value = infoClass.classId;
int
inCount = cmd.ExecuteNonQuery();
if
(inCount > 0)
{
MessageBox
.Show(
"Deleted Successfully"
,
"School Automation"
,
MessageBoxButtons
.OK,
MessageBoxIcon
.Information);
}
return
inCount;
}
catch
(
Exception
)
{
throw
;
}
}
Please tell how can overcome this error.
Post
Reset
Cancel
Answers (
1
)
Next Recommended Forum
database retrival value of zero, but linqpad is not zero
DataGridView CellDoubleClick Event Error