我在VB.NET中有一个Web服务函数,它将参数发送到SQL Server存储过程。
在已部署的计算机中,一切都能完美运行两个月。
但现在错误
过程或函数GetEmployeeDetails需要一个未提供的参数@Progress'
在已部署的计算机上仅发生一次。
错误之前和之后一切正常。
网络服务代码:
Public Function GetLocation(ByVal oldNumber As Integer, ByVal NewNumber As Integer, ByVal Location As String,ByVal Progress As String, ByVal Name As String, ByVal ID As String) As String
Try
Command1 = New SqlCommand("GetEmployeeDetails", connection1)
With Command1
.CommandType = CommandType.StoredProcedure
.Parameters.Add("@oldNumber", SqlDbType.Int).Value = oldNumber
.Parameters.Add("@NewNumber", SqlDbType.Int).Value = NewNumber
.Parameters.Add("@Location", SqlDbType.VarChar, 10).Value = Location
.Parameters.Add("@Progress", SqlDbType.Char, 10).Value = IIf(Progress = "", System.DBNull.Value, Progress)
.Parameters.Add("@Name", SqlDbType.VarChar, 50).Value = Name
.Parameters.Add("@ID", SqlDbType.VarChar, 50).Value = ID
.Connection.Open()
.ExecuteNonQuery()
.Connection.Close()
End With
存储过程参数:
ALTER PROCEDURE GetEmployeeDetails
(
@oldNumber AS INTEGER,
@NewNumber AS INTEGER,
@Location AS VARCHAR(10),
@Progress AS CHAR(1),
@Name AS VARCHAR(50),
@ID AS VARCHAR(50)
)
As
我只是想知道为什么在正确传递所有参数时发生错误?
答案 0 :(得分:0)
由于您在sql中将参数声明为CHAR(1),但在Vb.net中像Char(10)一样使用。
试试这个
ALTER PROCEDURE GetEmployeeDetails
(
@oldNumber AS INTEGER,
@NewNumber AS INTEGER,
@Location AS VARCHAR(10),
@Progress AS CHAR(10),
@Name AS VARCHAR(50),
@ID AS VARCHAR(50)
)
As