callin a stored procedure that uses 2 different databases

Discussion in 'ASP General' started by .nLL, Sep 1, 2007.

  1. .nLL

    .nLL Guest

    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
     
    .nLL, Sep 1, 2007
    #1
    1. Advertising

  2. .nLL

    .nLL Guest

    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$...
    > 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
    >
    >
    >
    >
     
    .nLL, Sep 1, 2007
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ken North
    Replies:
    0
    Views:
    618
    Ken North
    Jul 14, 2005
  2. Shalini
    Replies:
    1
    Views:
    527
    Jack Klein
    Jan 22, 2004
  3. Mike P
    Replies:
    0
    Views:
    3,328
    Mike P
    Jun 19, 2006
  4. error when callin matlab from c

    , Mar 18, 2006, in forum: C Programming
    Replies:
    1
    Views:
    314
    Grumble
    Mar 18, 2006
  5. Tech07

    On topic: Iran callin USA <something!>

    Tech07, Sep 30, 2009, in forum: C Programming
    Replies:
    1
    Views:
    285
    Nick Keighley
    Oct 1, 2009
Loading...

Share This Page