|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Tuesday, May 07, 2013 12:15 AM
Points: 123,
Visits: 502
|
|
i am passing table from C# to sql. on sql this is my code :
CREATE TYPE [dbo].[CampaignIdList] AS TABLE( [BLMJ] NVARCHAR(50) NOT NULL ) GO CREATE PROCEDURE [dbo].[casp_GetExist] @BLMJ_LIST CampaignIdList READONLY AS BEGIN SET NOCOUNT ON; Select * from @BLMJ_LIST
END GO
then i take the code as i see it on the profiler :
declare @p3 dbo.CampaignIdList insert into @p3 values(N'1247') insert into @p3 values(N'1261') insert into @p3 values(N'1277') insert into @p3 values(N'1279') insert into @p3 values(N'1289') select * from @p3 -->> isee that there is data in @p3 execute sp_executesql N'exec casp_GetExist',N'@BLMJ_LIST CampaignIdList READONLY',@p3
when i run the code that i take from the profiler, and i expect for result from the query : Select * from @BLMJ_LIST i get no rows as result. any idea why?
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Yesterday @ 5:50 PM
Points: 1,308,
Visits: 3,899
|
|
Because you are declaring a parameter for the sp_executesql to use, but not actually using it in the query to execute...
You can either change the last line to this:
execute sp_executesql N'exec casp_GetExist @BLMJ_LIST',N'@BLMJ_LIST CampaignIdList READONLY',@p3;
or this
exec casp_GetExist @BLMJ_LIST=@p3;
MM
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Yesterday @ 5:50 PM
Points: 1,308,
Visits: 3,899
|
|
Maybe what you really need to do is post the C# code as that seems to be calling wrong...
MM
|
|
|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Tuesday, May 07, 2013 12:15 AM
Points: 123,
Visits: 502
|
|
fixed the C# code :
SqlCommand cmd = new SqlCommand("casp_GetExist", cnt); SqlParameter parameter = new SqlParameter(); cmd.CommandType = CommandType.StoredProcedure; //The parameter for the SP must be of SqlDbType.Structured parameter.ParameterName = "@BLMJ_LIST"; parameter.TypeName = "CampaignIdList"; parameter.SqlDbType = System.Data.SqlDbType.Structured; parameter.Value = dataTable; cmd.Parameters.Add(parameter); SqlDataReader sqlDR = cmd.ExecuteReader();
but dont get recordset on :sqlDR
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Yesterday @ 5:50 PM
Points: 1,308,
Visits: 3,899
|
|
have you captured a trace of that new C# code running?
MM
|
|
|
|