Avatar of dvplayltd
Flag for Bulgaria

asked on 

Get data from UDF in SQL 2005 from C#

Hi experts!

  Im using C# 2008 , WinForm and need to get data from UserDefinedFunction in SQL 2005. I try follow code, but get error. Can you give me example how to get data from UDF ? My function return one string value.
I try like reader, with excuteScalar, but without luck.

SQL = "SELECT  dbo.fn_GetListEmailForCampaign(@bCampaignFile,@LCampaignID) AS Name1 ";
             // bool b1= gDs.ExecuteScalar(ref sObjUsetTo, SQL, null, 0, false);
              string sUserTo ; //= sObjUsetTo.ToString();
               w = 0;
               w++; g.PR[w].Type = System.Data.SqlDbType.Bit; g.PR[w].Value = 1; g.PR[w].Name = "@bCampaignFile";
               w++; g.PR[w].Type = System.Data.SqlDbType.BigInt; g.PR[w].Value = ID; g.PR[w].Name = "@LCampaignID";
              SqlDataReader reader = gDs.GetReader(SQL, g.PR, w);
             // string sUserTo = "";
              using (reader)
                  sUserTo = g.sVar(reader[0]); reader.Close();

Open in new window

.NET ProgrammingMicrosoft SQL Server

Avatar of undefined
Last Comment

8/22/2022 - Mon