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
Gabriel olayinka
NA
119
4.6k
Error while updating database
Mar 30 2018 12:58 AM
why am i getting this error
The parameterized query '(STUD_NAME nvarchar(4000),STUD_ID nvarchar(4000),ca_1nvarchar' expects the parameter 'STUD_NAME', which was not supplied.
Here is my code
con.Open();
try
{
CalculateTotal();
for
(
int
i = 0; i < dgAssessment.Rows.Count; i++)
{
string
cb = (
"update ASSESSMENTS set STUD_NAME=@STUD_NAME ,STUD_ID=@STUD_ID,CA_1=@CA_1,CA_2=@CA_2,CA_3=@CA_3,CA_4=@CA_4,EXAM=@EXAM,TOTAL=@TOTAL,GRADE=@GRADE,SUBJ_POSITION=@SUBJ_POSITION,REMARKS=@REMARKS,NO_OF_LESSONS=@NO_OF_LESSONS,ATTENDANCE=@ATTENDANCE where STUD_ID= '"
+ dgAssessment.Rows[i].Cells[
"StudentRef"
].Value +
"'"
);
cmd =
new
SqlCommand(cb);
cmd.Connection = con;
cmd.Parameters.AddWithValue(
"STUD_NAME"
, dgAssessment.Rows[i].Cells[
"Student_Name"
].Value);
cmd.Parameters.AddWithValue(
"STUD_ID"
, dgAssessment.Rows[i].Cells[
"StudentRef"
].Value);
cmd.Parameters.AddWithValue(
"CA_1"
, dgAssessment.Rows[i].Cells[
"ca1"
].Value);
cmd.Parameters.AddWithValue(
"CA_2"
, dgAssessment.Rows[i].Cells[
"CA2"
].Value);
cmd.Parameters.AddWithValue(
"CA_3"
, dgAssessment.Rows[i].Cells[
"CA3"
].Value);
cmd.Parameters.AddWithValue(
"CA_4"
, dgAssessment.Rows[i].Cells[
"CA4"
].Value);
cmd.Parameters.AddWithValue(
"EXAM"
, dgAssessment.Rows[i].Cells[
"EXAM"
].Value);
cmd.Parameters.AddWithValue(
"TOTAL"
, dgAssessment.Rows[i].Cells[
"TOTAL"
].Value);
cmd.Parameters.AddWithValue(
"GRADE"
, dgAssessment.Rows[i].Cells[
"GRADE"
].Value);
cmd.Parameters.AddWithValue(
"SUBJ_POSITION"
, dgAssessment.Rows[i].Cells[
"Position"
].Value);
cmd.Parameters.AddWithValue(
"NO_OF_LESSONS"
, dgAssessment.Rows[i].Cells[
"NoofLessons"
].Value);
cmd.Parameters.AddWithValue(
"ATTENDANCE"
, dgAssessment.Rows[i].Cells[
"Attendance"
].Value);
cmd.Parameters.AddWithValue(
"REMARKS"
, dgAssessment.Rows[i].Cells[
"Remark"
].Value);
cmd.ExecuteNonQuery();
}
//end for
MessageBox.Show(
"Record Updated Successfully"
);
}
catch
(Exception ex)
{
MessageBox.Show(ex.Message,
" ERROR MESSAGE"
, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
finally
{
con.Close();
}
//end finally
Reply
Answers (
2
)
retrieve data from azure table storage.
Token based Web Api authentication in asp.net MVC