我正在尝试使用带有参数的ODBC执行存储过程,但每次我都会得到以下内容:
错误[42000] [Microsoft] [ODBC SQL Server驱动程序] [SQL Server]过程或函数'aaPRO_CloseCall'需要参数'@FaultID',它未提供。
我的代码是:
Dim I As Integer = Convert.ToInt32(LogIDTextBox.Text)
Dim ConnString As String = "Dsn=Test"
Dim Conn As Odbc.OdbcConnection = New Odbc.OdbcConnection(ConnString)
Dim cmd As New Odbc.OdbcCommand("aaPRO_closecall", Conn)
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.AddWithValue("@FaultID", I)
Conn.Open()
cmd.ExecuteNonQuery()
Conn.Close()
我是Visual Studio的新手,我看不出有什么问题。如果有人能提供帮助,我将非常感激。
答案 0 :(得分:0)
这就是我最后所做的
'Create the ODBC connection
Dim Conn As Odbc.OdbcConnection = New Odbc.OdbcConnection(ConnString)
Conn.Open()
'Add the call to the stored procedure including the connection
Dim cmd As New Odbc.OdbcCommand("{ CALL aaPRO_closecall(?) }", Conn)
cmd.CommandType = CommandType.StoredProcedure
'add the parameter to the stored procedure
Dim MyParm As OdbcParameter = cmd.Parameters.Add("@FaultID", OdbcType.Int)
MyParm.Value = FL
'Execute the procedure
cmd.ExecuteNonQuery()
'clean up after
Conn.Close()
Conn.Dispose()
感谢您的帮助。