写了3个代码都说我 “begin”附近语法错误,之前也是这么写的,也没有找到错误,求助!!
存储过程:程序代码:
USE [WeMeet] GO /****** Object: StoredProcedure [dbo].[usp_Delete] Script Date: 06/15/2020 22:10:02 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO ALTER proc [dbo].[usp_Delete] @name char(50) as begin declare @err int delete from Player where pName=@name set @err=@@ERROR if(@err!=0)return -1 return 0 end
VB代码
程序代码:
Private Sub Command1_Click() Dim cmd As String, cc As Long On Error GoTo ErrorHandler If MsgBox("真的要删除玩家'" & Trim(DataGrid1.Columns(0).Text) & '吗?", vbYesNo, "信息") <> vbYes Then Exit Sub If DataGrid1.Row < 0 Then Exit Sub cmd = " begin tran " cmd = cmd & " declare @x int, @name char(50)" cmd = cmd & " set nocount on " cmd = cmd & " SET @name='" & DataGrid1.Columns(0) & "' " cmd = cmd & " Exec @x=usp_Delete @name " cmd = cmd & " select @x X" cmd = cmd & " if @x=0 commit else rollback " Adodc1.RecordSource = cmd Adodc1.Refresh cc = Val(Adodc1.Recordset.Fields(0)) If cc = 0 Then Adodc1.Refresh: DataGrid1.Refresh MsgBox "玩家信息删除成功!", , "提示": Exit Sub End If P0: MsgBox "发生未知错误,调用失败!", vbOKOnly: Exit Sub ErrorHandler: MsgBox (Err.Description & Chr(13) & Chr(10)) Resume P0 End Sub Private Sub Command2_Click() Unload Me aHome.Show vbModal End Sub