callin a stored procedure that uses 2 different databases

N

.nLL

when i use sql server manager to create and test belove sp its fine
but when i use it in my asp site i get erorr, because sp uses 2 different
databases to cretate its resulst. both dbs are in same server but i dont
know how to setup it in my asp page so it can call sp preoperly. here is
what i've got
------------------------------------------------------------------------
1 server
db one IP2COUNTRY
db two UPLOADED
-----------------------------------------
SP
----------------------------------------------------
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[sp_top20UploaderCountry]
As

select top 25 sum(HowManyFromCountry) as TotalUploads,MyCountry from
(
Select
Count(ip) as HowManyFromCountry,ip,
(
SELECT CountryCode FROM [IP2COUNTRY].[dbo].[ip_networks]
WHERE IpFrom = ( SELECT MAX(IpFrom) FROM
[IP2COUNTRY].[dbo].[ip_networks]
WHERE IpFrom <= (select [IP2COUNTRY].dbo.ip2int(uploads.ip))
) AND IpTo >= (select [IP2COUNTRY].dbo.ip2int(uploads.ip))
) as MyCountry
from uploads
group by ip
) as t Group by MyCountry order by TotalUploads desc
--------------------------------------------------------------------------


asp code that calls this sp
----------------------------------------
DbConnection="Provider=SQLOLEDB.1;Data Source=MYSERVER;Initial
Catalog=UPLOADED;User ID=USERNAME;Password=PASSWORD"
Set objRS = Server.CreateObject("ADODB.Recordset")
strSQL = "sp_top20UploaderCountry"
objRS.Open strSQL, DbConnection,1,1
 
N

.nLL

dont worry, done it.
all you need to to give access right to your current dbs user on other db
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,817
Latest member
DicWeils

Latest Threads

Top