?
Solved

LINQ using PROCs... aps.net c#

Posted on 2014-11-18
10
Medium Priority
?
121 Views
Last Modified: 2016-02-15
I am getting error with the following code:
           ListBox1.Items.Clear();
           var ps2 = wscgsContext.spGetData("John");
           foreach (spGetDataResult s2 in ps2)
           {
               ListBox1.Items.Add(s2.City);
           }
           

Open in new window


Question: How can I correct this?

LINQ below works fine (FYI, I do not run both codes at the same time):
           ListBox1.Items.Clear();
           var ps = from p in wscgsContext.Searches
                    where p.City == "New York"
                    orderby p.Last_Name
                    select p;
           foreach (Search s in ps)
           {
               ListBox1.Items.Add(s.Address);
           }

Open in new window

0
Comment
Question by:Mike Eghtebas
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
  • 2
10 Comments
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 40449900
What is the error?
0
 
LVL 34

Author Comment

by:Mike Eghtebas
ID: 40449912
Sorry,

Data doesn't show up in ListBox1 when running spGetData("John");

But with wscgsContext.Searches it data shows up in ListBox1.

When I step through, it doesn't go inside "foreach (spGetDataResult s2 in ps2)" loop.
0
 
LVL 63

Expert Comment

by:Fernando Soto
ID: 40449918
You state the following, "I am getting error with the following code:", what is the exact error message.
0
Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

 
LVL 34

Author Comment

by:Mike Eghtebas
ID: 40449924
Hi Fernando,

I didn't have my Coffee this morning, that is why I forgot to give the description of the problem. Please see my last post.

Mike
0
 
LVL 75

Assisted Solution

by:käµfm³d 👽
käµfm³d   👽 earned 600 total points
ID: 40449926
it doesn't go inside "foreach (spGetDataResult s2 in ps2)" loop.
That means there's nothing in ps2 to loop over. Have you tried executing your sproc manually within SSMS?
0
 
LVL 63

Accepted Solution

by:
Fernando Soto earned 1400 total points
ID: 40449927
If it is not going inside the foreach loop it is because the collection is empty. Are you sure that using the parameter "John" will return anything?
0
 
LVL 34

Author Comment

by:Mike Eghtebas
ID: 40449928
Yes, I have tested this proc in SSMS and it works fine.
0
 
LVL 34

Author Comment

by:Mike Eghtebas
ID: 40449931
re> "John" will return anything?

brb
0
 
LVL 63

Expert Comment

by:Fernando Soto
ID: 40449932
Can you post the stored procedure here please.
0
 
LVL 34

Author Comment

by:Mike Eghtebas
ID: 40449943
Fernando,

I need to get my coffee now. "John" was now a good criteria.

kaufmed,
I had tested with "Mike" in SSMS.

Thanks,

Mike
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question