问题描述
我在VB.NET的Web服务功能,将参数发送到SQL Server存储过程。
I have a web service function in VB.NET that will send parameters to a SQL Server stored procedure.
一切完美的作品在部署机器两个月。
Everything works perfectly for two months in the deployed machine.
但现在的误差
过程或函数GetEmployeeDetails预计但未提供参数@Progress
部署的机器上只发生一次。
occurred only once on the deployed machine.
前后误差一切工作正常。
Before and after the error everything works fine.
Web服务code:
Web service code:
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
存储过程PARAMS:
Stored procedure params:
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
我只是想知道,为什么当所有的参数都正确地传递出错?
I just want to know why the error occured when all the parameters are passed correctly?
推荐答案
既然你(1)在SQL,但像使用CHAR(10)Vb.net。
Since you are Declaring Parameter as CHAR(1) in sql but used like Char(10) in Vb.net.
试试这个
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
这篇关于过程或函数"程序名和QUOT;预计参数"参数名称"但未提供很少发生的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!