SqlException -E.Library-TableValueFunctions
Hi!
I'm using VS2005, C#, Enterprise Libraries 3.1, SQL Server Express 2005. When i try to execute a TableValueFunction (with one parameter "idCliente") the SQL server trows a SQL Exception -Error to request stored procedure. 'DameProcesosClienteId' is a TableValueFuntion-.
Does anybody the same problem and knows how to fix it?
I think is not a rights problem in Server because 'user' have a 'sysadmin' rights.
Thank you for you help!
[C# code]
Database db = DatabaseFactory.CreateDatabase();
DbCommand dbCommand = db.GetStoredProcCommand("DameProcesosClienteId");
db.AddInParameter(dbCommand, "idCliente", DbType.Int32, 4);
db.AddInParameter(dbCommand, "idCliente", DbType.String, 4); //i tried both
using (IDataReader dataReader = db.ExecuteReader(dbCommand)) //HERE!!!
{
while (dataReader.Read())
{
Console.WriteLine(dataReader["Dato"]);
}
}
[Fully Exception Text]
No se controló System.Data.SqlClient.SqlException
Message="Error en la petición procedimiento 'DameProcesosClienteId'. 'DameProcesosClienteId' es un objeto función con valores de tabla."
Source=".Net SqlClient Data Provider"
ErrorCode=-2146232060
Class=18
LineNumber=1
Number=2809
Procedure=""
Server="(local)\\SQLEXPRESS"
State=1
StackTrace:
en System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
en System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
en System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
en System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
en System.Data.SqlClient.SqlDataReader.ConsumeMetaData()
en System.Data.SqlClient.SqlDataReader.get_MetaData()
en System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
en System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
en System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
en System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
en System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
en System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
en System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior)
en Microsoft.Practices.EnterpriseLibrary.Data.Database.DoExecuteReader(DbCommand command, CommandBehavior cmdBehavior)
en Microsoft.Practices.EnterpriseLibrary.Data.Database.ExecuteReader(DbCommand command)
en System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
en System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
en Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
en System.Threading.ThreadHelper.ThreadStart_Context(Object state)
en System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
en System.Threading.ThreadHelper.ThreadStart()
[StoredProcedureCode]
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO
ALTER FUNCTION [dbo].[DameProcesosClienteId] (@__idCliente varchar (255)
)
RETURNS TABLE
AS RETURN (
SELECT PROCESOS.*
FROM PROCESOS
WHERE PROCESOS.idCliente=@__idCliente)