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
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