Linq to Sql stored procedure using two databases

Posted on 2012-08-31
Last Modified: 2012-09-07
I have a stored procedure that uses a table from each of two databases to return the needed data using one parameter.  It works fine on the database where it was created.  I have added it to the .dbml for that table in my program.  However, when I try to use it in the program, it returns an empty result.  Is it possible to get data from two databases into a result with linq to sql?  

my stored procedure:
SELECT   a.appID,
FROM         dbo.pTable p
INNER JOIN a on p.pID = a.pID
	where a.appID = @appID

Open in new window

my linq to sql statement:
Dim names = From n In db1.uspGetNameByAppID(globalAppID) Select n

Open in new window

Question by:McGurk1
    LVL 25

    Accepted Solution

    It shouldn't have created any problem. Just check if the parameter is being passed correctly or not.
    There is a suggestion. Actually , it shouldn't make much difference, but you can give it a try.
    Create a procedure to take the parameter and call the procedure instead of calling both the tables. This will give you performance enhancement as well.
    Or, create a view and call the view.

    Author Closing Comment


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    Naughty Me. While I was changing the database name from DB1 to DB_PROD1 (yep it's not real database name ^v^), I changed the database name and notified my application fellows that I did it. They turn on the application, and everything is working. A …
    In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

    760 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

    11 Experts available now in Live!

    Get 1:1 Help Now