SQL Server LinkServers

Posts   
 
    
kakaiya
User
Posts: 161
Joined: 20-Mar-2004
# Posted on: 18-Oct-2008 09:10:06   

Hi

I'm working on a project and thinking about how can we use LLBLGen Pro.

We have a SQL Server 2005 (Server A) and a Linked Server SQL Server 2000 (Server B)

ServerA has DB_A and tblCourse and fields like CourseID, CourseName, CourseLocation etc. as well as tblStudentCourse and fields like CourseID, StudentID etc.

ServerB (linked server) has DB_B and tblStudent and fields like StudentID, StudentName, Year etc.

Now we want to query data from ServerB (Linked Server) as well as ServerA together like...

SELECT ServerA.DB_A.dbo.tblStudentCourse.CourseID, ServerA.DB_A.dbo.tblStudentCourse.StudentID, ServerB.DB_B.dbo.tblStudent.StudentName, FROM ....... ..... WHERE SOME CONDITION (Predicate) here...

What is the best way to go about this? As in most of the cases we need CRUD in Server A while READ ONLY data access from Server B?

LLBLGenPro 2.6 Final (16 Oct 2008 latest release) Runtime Library: last release Templates: Adapter .NET Framework: .NET 2.0 Database: SQL Server 2005

regards

kaksss

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 18-Oct-2008 11:01:05   

Linked servers aren't supported. If you want to connect to the linked server's schema, you have to do that directly (and also create the project directly on that server). the reason is that a linked server could be anything so meta-data isn't really retrievable reliably.

Frans Bouma | Lead developer LLBLGen Pro
kakaiya
User
Posts: 161
Joined: 20-Mar-2004
# Posted on: 18-Oct-2008 12:35:29   

Thanks Otis.

I need some info-advice on this:

As application for DB_B is developed by 3rd party. We can only have read only access to this Database.

A SQL Server 2005 is running on a server with 2 (DB_A and DB_B) databases located on the same box - DB_A (we have full control of it) is setup as SQL2005 and DB_B (develop and maintain by 3rd party) is setup as SQL2000 database.

Still we will be able to generate LLBLGen DAL for DB_A and DAL for DB_B but the main thing is how can we fetch data from TWO different databases in a single query.

SELECT ServerA.DB_A.dbo.tblStudentCourse.CourseID, ServerA.DB_A.dbo.tblStudentCourse.StudentID, ServerB.DB_B.dbo.tblStudent.StudentName, FROM ....... ..... WHERE SOME CONDITION (Predicate) here...

As I'm wondering how can I have a DataAccessAdapter that can connect to two databases?

Thanks.

kaksss

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
kakaiya
User
Posts: 161
Joined: 20-Mar-2004
# Posted on: 20-Oct-2008 13:52:28   

Thanks Walaa.

I have read through this.

Still have a query about how LLBLGen can able to generate full name like ServerName.DBName.dbo.TblName.FldName in query?

Do I have to use catalog overwrite? Can you please post 2 lines of code for this?

Thanks.

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 20-Oct-2008 15:39:22   

You have a valid point.

You could 'hack' that away with changing the SqlServerDQE a bit, i.e. in CreateObjectName in the SqlServerSpecificCreator.cs file

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 20-Oct-2008 21:27:14   

plus... rename DBName to Server.DBName using catalog name overwriting. However, you then have to alter the DQE code a bit otherwise you'll get [Server.DBName] in the query.

Frans Bouma | Lead developer LLBLGen Pro