Re: how to connect to multiple database mssql?



can you make an exaple with sql server?

i have these 2 connection string:

You don't need 2 connection strings. You need 1 connection string.
It is provider that does the work _NOT_ ADO
All that matters is whether
(i) both databases are on same server
(ii) databases are on different servers

In the case of (i), with 2 databases called fred, gladys
- get a connection, using one of the databases
- populate a recordset or similar with something like

SELECT f.field1,g.field2 FROM
fred.dbo.table1 f JOIN gladys.dbo.table2 g ON f.field3=g.field4
WHERE ...
ORDER BY 1,2

and SQL Server will do what is join 2 tables from 2 different databases that
it is managing.

In the case of (ii), you need to run the Stored Procedure sp_addlinkedserver
on Query Analyser first so that one server is aware of the 2nd server's
existence
See http://msdn2.microsoft.com/en-us/library/ms190479.aspx

call it server2

and then after that it is similar.

SELECT f.field1,g.field2 FROM
fred.dbo.table1 f JOIN server2.gladys.dbo.table2 g ON f.field3=g.field4
WHERE ...
ORDER BY 1,2

Stephen Howe




connStr1,connStr2

and this query to do:
"SELECT title FROM conn1.dbo.tableTitleHolder UNION ALL select title
FROM conn2.dbo.tableTitleHolder WHERE..."

i've tryed sqlConnection(connStr1+","+connStr2),
but i get an error



.



Relevant Pages

  • Re: External Connection String
    ... All databases are NOT created equal. ... it would help if you posted the entire Connection String. ... > connect to a database on another server supposely in the network. ... > I can ping the server by usually ping dbservername. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: External Connection String
    ... All databases are NOT created equal. ... it would help if you posted the entire Connection String. ... > connect to a database on another server supposely in the network. ... > I can ping the server by usually ping dbservername. ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Error trying to connect to local database - What is going on?
    ... I am certain that it is not database connectivity per se that is the problem, as most of the databases are working fine. ... This server runs some e-commerce sites that use common code, so those databases have a common structure. ... All I did was change the name of the server in the connection string. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: AS2005 ... what is wrong with it?
    ... What I have seen is that the dev server is *faster* than the prod server ... And does your dev server also have all 6 databases with all these roles? ... When I restore the "PROV" i got approx 20 sec. ... Starting from an empty data folder should show if this theory is true ...
    (microsoft.public.sqlserver.olap)
  • Re: OLE DB connection string in SharePoint for Sybase ASA
    ... I wen to the Sybase site and found a reference to Connection String ... > where I WANT it to say Database Connections. ... > and up pops a Data Source Properties Window. ... > Server Error: An error occurred while retrieving the list of Databases ...
    (microsoft.public.frontpage.client)