我有一个非常简单的查询,例如:
FactoryBot.define do
factory :catalog do
description "Catalog description"
…
trait :with_courses do
after :create do |catalog|
courses = FactoryBot.create_list :course, 2
catalog.courses << courses
catalog.save
end
end
end
end
但是我真的不知道为什么在我的BEGIN TRY
BEGIN TRAN;
DECLARE @CurrentPassword VARCHAR(255) = (SELECT TOP 1 [Password]
FROM Employee
WHERE @EmpGuid = EmpGuid)
IF (@Password = @CurrentPassword)
UPDATE [Employee]
SET [Password] = @NewPassword
WHERE @EmpGuid = EmpGuid
SELECT 1;
ELSE
SELECT 2;
COMMIT TRAN
END TRY
BEGIN CATCH
ROLLBACK TRAN
END CATCH
子句中得到
“ ELSE”附近的语法不正确
我在做什么错?问候
答案 0 :(得分:1)
您想在Private Sub dg_CellEndEdit(ByVal sender As Object, ByVal e As DataGridViewCellEventArgs) Handles dg.CellEndEdit
dg.Rows(e.RowIndex).Cells(e.ColumnIndex).Value = String.Format(dg.Rows(e.RowIndex).Cells(e.ColumnIndex).Value, "c")
End Sub
之后有个以上语句,您必须使用 IF
块-像这样:>
BEGIN .... END
答案 1 :(得分:0)
显式使用begin . . end
BEGIN TRY
BEGIN TRAN
DECLARE @CurrentPassword VARCHAR(255) = (SELECT TOP 1 [Password]
FROM Employee
WHERE @EmpGuid = EmpGuid)
IF (@Password = @CurrentPassword)
BEGIN
UPDATE [Employee]
SET [Password] = @NewPassword
WHERE @EmpGuid = EmpGuid
SELECT 1
END
ELSE
BEGIN
SELECT 2
END
COMMIT TRAN
END TRY
BEGIN CATCH
ROLLBACK TRAN
END CATCH