• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 643
  • Last Modified:

Linq to Sql stored procedure using two databases

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, p.name
FROM         dbo.pTable p
INNER JOIN db2.dbo.app 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

0
McGurk1
Asked:
McGurk1
1 Solution
 
TempDBACommented:
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.
0
 
McGurk1Author Commented:
Thanks
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now