Solved

LINQ using PROCs... aps.net c#

Posted on 2014-11-18
10
120 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
Industry Leaders: 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!

 
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 150 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 350 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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

707 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