c# - How to get list of values from SQL stored procedure using ExecuteSqlCommand -


i trying list of values in sql table output based on input parameter using following sql stored procedure.

create procedure getfirstnames   @lastname nvarchar(128),   @firstnames nvarchar(128) output     set @firstnames = (select firstname namestable lastname = @lastname) go 

i using following code list of first names table.

sqlparameter lastnameparam = new sqlparameter("@lastname", "smith"); sqlparameter firstnamesparameter = new sqlparameter("@firstnames", sqldbtype.nvarchar, 128); firstnamesparameter.direction = parameterdirection.output; string sql = string.format("exec dbo.getfirstnames {0}, {1};",     lastnameparam.parametername,     firstnamesparameter.parametername); context.database.executesqlcommand(sql, lastnameparam, firstnamesparameter); 

when call executesqlcommand method following error:

subquery returned more 1 value. not permitted when subquery follows =, !=, <, <= , >, >= or when subquery used expression. 
  1. how can resolve query error can list of first names?
  2. how can return list , use in c# code?

i appreciate if can me this. thanks.

create procedure getfirstnames   @lastname nvarchar(128)   set nocount on select firstname namestable lastname = @lastname go 

will fix query portion , give enumerable result set. rest exercise op.


Comments

Popular posts from this blog

account - Script error login visual studio DefaultLogin_PCore.js -

xcode - CocoaPod Storyboard error: -