sql server - Stored Procedure with output parameters connected to method in C# -


do see blatantly wrong line:

commasepstring1 = com.parameters["@commasepstring"].value.tostring(); 

it shows error like:

object reference not set instance of object.

for short, c# method looks like:

public static datatable getfilmdetails(string filmid, out string commasepstring1) 

it takes following stored procedure (that executes correctly on own):

com.commandtext = "cataloggetfilmdetails2"; 

and since @commasepstring output parameter in stored procedure, in c# have this:

param = com.createparameter(); param.parametername = "@commasepstring"; param.direction = parameterdirection.output; param.dbtype = dbtype.string; com.parameters.add(param);  commasepstring1 = com.parameters["@commasepstring"].value.tostring(); 

if curious stored procedure, starts this: create procedure cataloggetfilmdetails2

(@filmid int, @commasepstring varchar(50) output) 

the sp inserts rows table variable based on joins, puts values column x table string comma separated values:

select @commasepstring  = stuff((select ', ' + categ  @filme1 xml path('')), 1,1,'') 

then selects table.

thank patience read this. more clear if published entire code stored procedure , c# method? not sure if allowed , worried might lengthy read.

ps: there must something wrong commasepstring! code worked before added in both places.

you should set breakpoint on offending line, should examine parameters collection check if parameter exists.
if exists, check if value null.
in case .tostring() give error described.


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -