Bug In SqlCommandBuilder.DeriveParameters?

May 30, 2008


Hi there

We tried to use SqlCommandBuilder.DeriveParameters on .Net Compact FW 2.0.

It does pull in parameters of the stored procedure and the parameters do look valid (right quantity, right data types etc).
However as soon as one tries to execute the command populated with DeriveParameters an internal exeption occurs which gives no clue about what it might be, just a general error somewhere deep in a procedure which has "Internal" postfix in its name.

If we run that same executable compiled for compact framework 2.0 on a regular PC with "big" FW, it runs perfectly and no problems occur. That makes me think there's a bug with DeriveParameters in Compact FW 2.0 which is not present in the regular FW.

Is there anything we can do?
We can populate Parameters manually although that doesn't really suit us, we also can read SCHEMA information to populate them for any given procedure, but we'd like to get DeriveParameters work instead.

View 1 Replies


ADVERTISEMENT

Caching Or Reusing Parameters Populated With SqlCommandBuilder.DeriveParameters

Mar 3, 2004

Hello,

I have a real heartache with runtime parameter interogation on my DB.
Sure I get the latest and greatest and sure I don't have to type in all those lovely parameter types..but...the hit I take on performance for making no less then 3 DB hits for each SqlAdapter is unreasonable!

So ...I like the idea of maybe calling it once for all my stored procs on application startup...and then maybe saving this in CacheObject.

My problem is that I can't see where you can even serialize a SqlParametersCollection or even for that matter assign it to a Command object. Can you cache a command object ?

LOL

I think I may just have to write some generic routine for creating and populating my command objects based on a key (type) and then use that to fetch my command.Update,
command.Insert and command.

I would like to use the new AsynchBlock to do the fetching of the stored proc parameters and then just pull them from the Cache object....put a file watch so that if the DB's change my params it re-pulls them again.

*nice*.....

Then I get the best of both worlds...caching...and no parameter writing...

Eric

View 4 Replies View Related

DeriveParameters Throws When Called Against A C# Function?

Aug 24, 2006

When I call DeriveParameters against a function written in SQLCLR function it throws an exception. I've been working on this a little while and haven't found a fix. I understand that I could write additional code to do the same work DeriveParameters does, but it seems like this should work.

This is the exception thrown:


[InvalidOperationException: The stored procedure 'GSI.Utils.IsMatch' doesn't exist.]

The function is defined as


CREATE FUNCTION [Utils].[IsMatch](@Value [nvarchar](4000), @RegularExpression [nvarchar](4000))
RETURNS [bit] WITH EXECUTE AS CALLER
AS
EXTERNAL NAME [RegularExpressionsHelper].[UserDefinedFunctions].[IsMatch]

The C# function is defined as:


[Microsoft.SqlServer.Server.SqlFunction(IsDeterministic=true)]
public static SqlBoolean IsMatch(SqlString Value, SqlString RegularExpression)
{
Regex rx = new Regex( RegularExpression.ToString() );
string s = Value.ToString();

return new SqlBoolean(rx.IsMatch(s));
}

This is the code I'm using to call DeriveParameters:


static void Main(string[] args)
{
using (SqlConnection conn = new SqlConnection(m_GetConnectionString()))
{
conn.Open();

SqlCommand myCommand = new SqlCommand("GSI.Utils.IsMatch", conn);
myCommand.CommandType = System.Data.CommandType.StoredProcedure;
SqlCommandBuilder.DeriveParameters(myCommand);
}
}

I found that DeriveParameters seems to call sp_procedure_params_managed and when I call it myself it returns the parameters correctly for T-SQL functions, but returns no records when I specify a SQLCLR function.


DECLARE @procedure_name sysname;
DECLARE @group_number int;
DECLARE @procedure_schema sysname;
DECLARE @parameter_name sysname;

SET @procedure_name = 'IsMatch';
SET @group_number = 1;
SET @procedure_schema = 'Utils';
SET @parameter_name = null;

DECLARE @RC int

EXECUTE @RC = [GSI].[Sys].[sp_procedure_params_managed]
@procedure_name
,@group_number
,@procedure_schema
,@parameter_name


I'm able to execute the function without issue and I'm able to use DeriveParameters against everything in the database except C# based functions (and I've tried others besides IsMatch). I'm attempting to run DeriveParameters from a console application and from ASP.NET, both running .NET 2.0.

I've experienced the same behavior in these versions:


SQL Server 2005 Enterprise Edition RTM (MSDN Image on Virtual Server)
SQL Server 2005 Enterprise Edition SP1 (MSDN Image on Virtual Server)
SQL Server 2005 Enterprise Edition SP1 + Hotfix kb918222 (MSDN Image on Virtual Server)
SQL Server 2005 Developer Edition SP1

Has anyone else seen similar behavior?

Any advice would be greatly appreciated -- Thanks

Steve

View 4 Replies View Related

EnterpriseLibrary Multi Owner Stored Procs DeriveParameters Failure

Oct 11, 2006

Hi

I am having diffuculty with multi owner stored procs with enterprise library deriveparameters.

Eg:

Create proc dbo.test @p1 int as select 'hi'

create proc bob.test @p1 int as select 'hi'

Deriveparameters appears to tell us the wrong number of parameters. I gather it is getting ALL the parameters for all procs called 'test' regardless of the owner.



If anyone can give me some guidance on this I would appreciate it!



Rich

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved