在下面的代码中,命令执行但没有更新。主要问题是SQL Server 数据库中将 IDNumber设置为IsIdentity的主要问题。如果有人可以帮助我,我将不胜感激。
If rbnCore.Checked = True Then
subject = "Core"
Else : subject = "Elective"
End If
qry = "Update ProgramDetails.Subjects set SubjectCode=@SubjectCode,SubjectName=@SubjectName,SubjectType=@SubjectType,UserID=@UserID,Password=@Password where IDNumber='" & txtIDNumber.Text & "'"
cmd = New SqlCommand(qry, cn)
cmd.Parameters.Add(New SqlParameter("@SubjectCode", txtSubjectCode.Text))
cmd.Parameters.Add(New SqlParameter("@SubjectName", txtSubName.Text))
cmd.Parameters.Add(New SqlParameter("@SubjectType", subject))
cmd.Parameters.Add(New SqlParameter("@UserID", txtUserName.Text))
cmd.Parameters.Add(New SqlParameter("@Password", txtPassword.Text))
cmd.ExecuteNonQuery()
MessageBox.Show("Record successfully updated", "Updated", MessageBoxButtons.OK, MessageBoxIcon.Information)
showgrid()
End If