这是我进行更新的存储过程,当我使用 SQL Server 测试该过程时,它运行良好。
ALTER PROCEDURE [TKSFlex].[UpdateComment]
-- Add the parameters for the stored procedure here
@Comment char(50),
@Employee char(25)
AS
BEGIN TRANSACTION
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT On;
-- Insert statements for procedure here
Update whiteboard set Comment = @Comment
where Employee = @Employee
COMMIT
这是单击更新按钮时执行的代码
Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal es System.EventArgs) Handles btnUpdate.Click
InputsModule.Employee = "'Mathe BF'"
Objconn.Open()
dbcommand.Connection = Objconn
dbcommand.CommandType = CommandType.StoredProcedure
dbcommand.CommandText = "[TKSFlex].[UpdateComment]"
dbcommand.Parameters.AddWithValue("@Comment", txtComment.Text)
dbcommand.Parameters.AddWithValue("@Employee", InputsModule.Employee)
'dbcommand.Parameters.Add("@Comment", SqlDbType.Char).Value = txtComment.Text
'dbcommand.Parameters.Add("@Employee", SqlDbType.Char).Value = InputsModule.Employee
Dim i As Integer = 0
Try
i = dbcommand.ExecuteNonQuery()
Catch ex As SqlException
MsgBox("failed")
End Try
Objconn.Close()
End Sub
执行查询时表没有更新并且没有抛出异常,这意味着代码确实被执行但没有对数据库进行修改,我只是不确定我哪里出错了