callin a stored procedure that uses 2 different databases

callin a stored procedure that uses 2 different databases

am 01.09.2007 22:18:08 von noone

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

Re: callin a stored procedure that uses 2 different databases

am 01.09.2007 22:30:25 von noone

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



".nLL" wrote in message
news:4OjCi.112192$p7.56942@fe2.news.blueyonder.co.uk...
> 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
>
>
>
>