Public Sub cleanTables(ByVal prOKDel As Short) Dim sqlParams(1) As sqlParameter Dim sqlProcName As String sqlProcName = "db.dbo.sp_mySP" sqlParams(1) = New sqlParameter("@OKDel",prOKDel) Try dbConn.SetCommandTimeOut(0) dbConn.ExecuteNonQuery(CommandType.StoredProcedure,sqlProcName,sqlParams) Catch ex As Exception Finally End Try End Sub
在那儿
CommandType.StoredProcedure...CommandType.Function sqlParams(1) = New sqlParameter("@OKDel",prOKDel)...
最后是datatable dt = dbConn.Execute(CommandType.StoredProcedure,sqlParams)
谢谢
抱歉,没有办法直接运行功能.使用sql Text命令调用它
Public Sub RunFunction(ByVal input As Short) Using myConnection As New Data.sqlClient.sqlConnection Using myCommand As New Data.sqlClient.sqlCommand("Select dbo.MyFunction(@MyParam)",myConnection) myCommand.CommandType = CommandType.Text myCommand.Parameters.Add(New Data.sqlClient.sqlParameter("@MyParam",input)) myCommand.CommandTimeout = 0 Try myCommand.ExecuteNonQuery() Catch ex As Exception End Try End Using End Using End Sub
或绕过它的程序……
Create Procedure RunMyFunction(@MyParam as int) Select * FROM dbo.MyFunction(@MyParam) Go