Quantcast
Channel: ADO.NET, Entity Framework, LINQ to SQL, NHibernate
Viewing all articles
Browse latest Browse all 1698

Return a list of user names

$
0
0

Hello,

I have a stored procedure, when I execute it with the right parameter it returns 3 user names like this in one row in SQL: 

User1 -- User2 ---User3

John---- Mike-----Jim

I am trying to display this complete list of users in a field on the webpage as shown above in the row. However when I pass the necessary parameter from the website to SQL, I only get the first name back, in this case John. Here is the Dapper ORM code that calls the stored procedure: 

  public List<String> GetUsers(string locNo)

        {

            List<String> Users = new List<String>();

            using (IDbConnection conn = GetConnection())

            {

                try

                {

                    var parameters = new DynamicParameters();

                    parameters.Add("@LocNo", locNo);

                    conn.Open();

                    Users = conn.Query<String>("dbo.spGetUsers",

                        param: parameters,

                        commandType: CommandType.StoredProcedure).ToList();

                }

                catch (Exception e)

                {

                    throw e;

                }

                return Users; //Users only contain the first user and 2 other users are missing, I need a list of all 3 users here. 

            }

        }

Thanks


Viewing all articles
Browse latest Browse all 1698

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>