Solved

LINQ using PROCs... aps.net c#

Posted on 2014-11-18
10
114 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
  • 5
  • 3
  • 2
10 Comments
 
LVL 75

Expert Comment

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

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 62

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
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
LVL 33

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 62

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 33

Author Comment

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

Author Comment

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

brb
0
 
LVL 62

Expert Comment

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

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

813 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now