Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Return a scalar value from SQL Server 2000 UDF
Message
From
26/09/2005 12:34:52
 
General information
Forum:
ASP.NET
Category:
ADO.NET
Miscellaneous
Thread ID:
01053027
Message ID:
01053114
Views:
8
Hi Pete,

I did a quick test using the MS Application Block to call a user defined function with no problem. Here's the form of the code I used:
string strConn = "server=localhost;Integrated Security=yes; ...";

// Set up the SQL Connection String and Parameters array
SqlParameter[] arParms = new SqlParameter[2];
arParms[0] = new SqlParameter("@cUnknown", SqlDbType.VarChar, 10);
arParms[0].Value = "MyValue";

arParms[1] = new SqlParameter("@MasterRef", SqlDbType.VarChar, 10);
arParms[1].Direction = ParameterDirection.ReturnValue;

SqlHelper.ExecuteNonQuery(strConn, CommandType.StoredProcedure, "dbo.ResolveToMaster", arParms);

string MyValue = arParms[1].Value.ToString();
Bill

>Hello All, could someone please help me out here, how do I call the SQL Server 2000 function below using C# and ADO.Net, I've tried treating it like a stored proc but without success
>
>
>
>FUNCTION ResolveToMaster (@cUnknown varchar(10))
>RETURNS varchar(10)
>AS
>begin
>
>
>declare @MasterRef varchar(10)
>
>select @MasterRef = null
>
>
>select  @MasterRef = (Select Distinct MasterRef from Claim where MasterRef =  @cUnknown)
>
>if @MasterRef is null
>begin
>	select  @MasterRef = (Select Distinct MasterRef from  Claim where CustomerRef =  @cUnknown)
>	
>end
>
>if @MasterRef is null
>	begin
>		select  @MasterRef = (Select Distinct MasterRef from Claim where ClaimRef =  @cUnknown)
>		
>	end
>
>
>Return @MasterRef
>end
>
>
>
>
>what I'm trying to achieve here is, to allow a user to enter either of three different numbers and resolve the number to a master reference ( their idea not mine !?? )
William A. Caton III
Software Engineer
MAXIMUS
Atlanta, Ga.
Previous
Reply
Map
View

Click here to load this message in the networking platform