Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8037057
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T02:48:44+00:00 2026-06-05T02:48:44+00:00

Do you see something blatantly wrong with this line: commaSepString1 = com.Parameters[@CommaSepString].Value.ToString(); It shows

  • 0

Do you see something blatantly wrong with this line:

commaSepString1 = com.Parameters["@CommaSepString"].Value.ToString();

It shows an error like:

Object reference not set to an instance of an object.

For short, the C# method looks like:

public static DataTable GetFilmDetails(string filmId, out string
commaSepString1)

It takes the following stored procedure (that executes correctly on its own):

com.CommandText = "CatalogGetFilmDetails2";

And since @CommaSepString is an output parameter in the stored procedure, in C# I 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 you are curious about the Stored Procedure, it starts like this:
CREATE PROCEDURE CatalogGetFilmDetails2

(@FilmID int, @CommaSepString VARCHAR(50) OUTPUT) AS

The SP inserts some rows into a table variable based on some joins, it puts all values from column x from that table into a string with comma separated values:

SELECT @CommaSepString 
= STUFF((SELECT ', ' + Categ  FROM @Filme1 FOR XML PATH('')), 1,1,'')

then it selects the table.

Thank you for the patience to read this. Would it be more clear if I published the entire code for the stored procedure and the C# method? Not sure if I am allowed that and worried it might be too lengthy to read.

PS: There must be something wrong about the commaSepString! The code worked perfectly before I added it in both places.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T02:48:46+00:00Added an answer on June 5, 2026 at 2:48 am

    You should set a breakpoint on the offending line, then you should examine your parameters collection to check if the parameter exists.
    If it exists, then check if its value is null.
    In this case the .ToString() will give you the error described.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I often see something like attribute in error messages. What is this? Are there
it's common to see something like this in code, hopefully only during development: //XXX:
From time to time I see something like this: class Clazz { private int
So I'm trying to see if something like this is possible WITHOUT using database.
I see something strange like: http://github.com/zoul/Finch.git Now I'm not that CVS, SVN, etc. dude.
If I see something like: if(Request[Email]) { } What does this actually mean? Where
In x86-64 assembly, I see something like this for my main function... push %rbp
In most examples I found on the Internet , I see something like this
Do you see something wrong in this insertion?? It does not work for me..
Does somebody see something wrong with this? I have an UIAltertView but get an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.