[Solved] incorrect syntax near keyword where [closed]


It seems for what you are trying to do, that what you need is an UPDATE statement and not an INSERT as you are writing. This seems a much more appropiate query:

UPDATE GradeTable 
SET Grade = @grade, 
    UserID = @UserID, 
    RegDate = @RegDate 
WHERE StudentID = @StudentID AND CourseID = @CourseID

Note that I used parameters and not the value of your textbox. This is because you are being vulnerable to one of the most common database security flaws that is SQL Injection.

Use that text for your query, and then you can add your values to the query this way:

cmd.Parameters.AddWithValue("@grade", TxtGrade.Text.Trim);
cmd.Parameters.AddWithValue("@UserID", UserID);
//AND SO ON WITH OTHER PARAMETERS

Assumming cmd is your SqlCommand

2

solved incorrect syntax near keyword where [closed]