Use 2 bases on same server

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Mario9
Posts: 8
Joined: Fri 03 Feb 2012 19:51
Location: QUEBEC

Use 2 bases on same server

Post by Mario9 » Tue 05 Nov 2013 14:17

Hi

I have a problem with my connection on SqlServer

I will like to use 2 tables on 2 bases different on the same serveur Mssql.

Do you have example to connect 2 bases on the same server and after connection use 2 tables

One Base is easy. How do you do for the second base to connect.

Excuse my English...

Mario

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Use 2 bases on same server

Post by AlexP » Wed 06 Nov 2013 09:34

hello,

To access tables from different databases using one connection, you should explicitly specify database names before table names, for example:

Code: Select all

SELECT * FROM Northwind.dbo.Products;
Or use 'Use' to specify the database you want to work with:

Code: Select all

USE Northwind;
SELECT * FROM dbo.Products;
P.S. The user, under which you are logging in the server, must have proper rights for the used databases.

Mario9
Posts: 8
Joined: Fri 03 Feb 2012 19:51
Location: QUEBEC

Re: Use 2 bases on same server

Post by Mario9 » Wed 06 Nov 2013 15:10

Tank you

I have one question again

My application use a MsTable and Msdatasource for my first base no problem my connection
use Msconnection1 to connect my server and base How to connect the second base with MsTable

Base one
1= MsTable1.tablename:='Nom' because Table1 is connect on first base

Base two
2= MsTable2.tablename:='adresse' or MsTable2.tablename:='Base2.adresse.dbo'

Thank you again

Mario

AndreyZ

Re: Use 2 bases on same server

Post by AndreyZ » Thu 07 Nov 2013 09:09

Here is a code example:

Code: Select all

MSTable1.TableName := 'DatabaseName1.SchemaName1.TableName1';
MSTable2.TableName := 'DatabaseName2.SchemaName2.TableName2';

Mario9
Posts: 8
Joined: Fri 03 Feb 2012 19:51
Location: QUEBEC

Re: Use 2 bases on same server

Post by Mario9 » Thu 07 Nov 2013 15:31

Thank you

I appreciate your support

Your explains was very good.My test is ok.

Thank again

Mario

AndreyZ

Re: Use 2 bases on same server

Post by AndreyZ » Thu 07 Nov 2013 15:48

I am glad I could help. If any other questions come up, please contact us.

Post Reply