Home All Groups Group Topic Archive Search About

Querying Indexing Services from ASP.Net page

Author
28 Dec 2005 5:19 PM
C Jay Pemberton Jr
I am attempting to do the following, query indexing services through SQL
Server

SQL Server 2000/Visual Studio 2003

I have a linked server created called Web_service that points to a Server
running Indexing Services

I have created a stored procedure that is as follows:

CREATE    procedure spQueryActivitiesWithIndex

@ActToDate varchar(20) = NULL,
@ActFromDate varchar(20)= NULL,
@CaseNumber varchar(13) = NULL,
@FullText varchar(3000) = NULL,
@OrderBy varchar(50) = NULL

as

declare @SQLStr varchar(2000)

Set @SQLSTR = 'SELECT va.*, LEFT(FILENAME, 21) AS Filename,
LEFT(REVERSE(SUBSTRING(REVERSE(DIRECTORY), 1, CHARINDEX(''\'',
REVERSE(DIRECTORY)) - 1)) ' +
                       ' + ''/'' + FILENAME, 40) AS Relative_Filename, RANK,
HITCOUNT, CHARACTERIZATION FROM OPENQUERY(web_content,' +
                      '''SELECT FileName, Directory, Rank, Hitcount,
Characterization FROM psc017.docket..SCOPE() WHERE '

if len(@FullText) > 0
   Set @SQLSTR = @SQLSTR + ' CONTAINS(''''' + @FullText + ''''') AND '

Set @SQLSTR = @SQLSTR + ' filename <> ''''index.htm'''' ORDER BY rank
desc'') Q' +
  ' INNER JOIN [Docket].[dbo].[ViewCaseActivityWithFileNameExt]  VA on
VA.txtScanFileName = Q.FileName ' +
  ' WHERE VA.txtActivityType = ''Order'''

if len(@CaseNumber) > 0
   Set @SQLSTR = @SQLSTR + ' AND VA.txtCaseNumber like ''%' + @CaseNumber +
'%'''

if Len(@ActToDate) > 0
  begin
    if Len(@ActFromDate) > 0
      Set @SQLSTR = @SQLSTR + ' AND VA.dteActivity between ''' + @ActToDate
+ ''' and ''' + @ActFromDate + ''''
    else
     Set @SQLSTR = @SQLSTR + ' AND VA.dteActivity = ''' + @ActToDate + ''''
  end

if Len(@Orderby) > 0
  Set @SQLSTR = @SQLSTR + ' ORDER BY VA.' + @OrderBy

--print @SQLSTR
EXEC (@SQLSTR)

GO

I can run this fine from SQL Server becuase I have admin rights, but when I
run this from within my ASP.Net app with the following code, I get the
following error message.

DsIndex1.Tables("spQueryActivitiesWithIndex").Clear()

daspQueryActivitiesWithIndex.Fill(DsIndex1, "daspQueryActivitiesWithIndex")



Login failed for user '(null)'. Reason: Not associated with a trusted SQL
Server connection.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: Login failed for user
'(null)'. Reason: Not associated with a trusted SQL Server connection.

I am new to ASP.NET so any help would greatly be apreciated.

Author
28 Dec 2005 5:31 PM
Mr Newbie
You need to Add the ASPNET account to the Database you have created the
Index in.

--
Best Regards

The Inimitable Mr Newbie  º¿º



Show quoteHide quote
"C Jay Pemberton Jr" <jpember***@psc.state.wv.us> wrote in message
news:%23TZyiL9CGHA.3784@TK2MSFTNGP15.phx.gbl...
>I am attempting to do the following, query indexing services through SQL
> Server
>
> SQL Server 2000/Visual Studio 2003
>
> I have a linked server created called Web_service that points to a Server
> running Indexing Services
>
> I have created a stored procedure that is as follows:
>
> CREATE    procedure spQueryActivitiesWithIndex
>
> @ActToDate varchar(20) = NULL,
> @ActFromDate varchar(20)= NULL,
> @CaseNumber varchar(13) = NULL,
> @FullText varchar(3000) = NULL,
> @OrderBy varchar(50) = NULL
>
> as
>
> declare @SQLStr varchar(2000)
>
> Set @SQLSTR = 'SELECT va.*, LEFT(FILENAME, 21) AS Filename,
> LEFT(REVERSE(SUBSTRING(REVERSE(DIRECTORY), 1, CHARINDEX(''\'',
> REVERSE(DIRECTORY)) - 1)) ' +
>                       ' + ''/'' + FILENAME, 40) AS Relative_Filename,
> RANK,
> HITCOUNT, CHARACTERIZATION FROM OPENQUERY(web_content,' +
>                      '''SELECT FileName, Directory, Rank, Hitcount,
> Characterization FROM psc017.docket..SCOPE() WHERE '
>
> if len(@FullText) > 0
>   Set @SQLSTR = @SQLSTR + ' CONTAINS(''''' + @FullText + ''''') AND '
>
> Set @SQLSTR = @SQLSTR + ' filename <> ''''index.htm'''' ORDER BY rank
> desc'') Q' +
>  ' INNER JOIN [Docket].[dbo].[ViewCaseActivityWithFileNameExt]  VA on
> VA.txtScanFileName = Q.FileName ' +
>  ' WHERE VA.txtActivityType = ''Order'''
>
> if len(@CaseNumber) > 0
>   Set @SQLSTR = @SQLSTR + ' AND VA.txtCaseNumber like ''%' + @CaseNumber +
> '%'''
>
> if Len(@ActToDate) > 0
>  begin
>    if Len(@ActFromDate) > 0
>      Set @SQLSTR = @SQLSTR + ' AND VA.dteActivity between ''' + @ActToDate
> + ''' and ''' + @ActFromDate + ''''
>    else
>     Set @SQLSTR = @SQLSTR + ' AND VA.dteActivity = ''' + @ActToDate + ''''
>  end
>
> if Len(@Orderby) > 0
>  Set @SQLSTR = @SQLSTR + ' ORDER BY VA.' + @OrderBy
>
> --print @SQLSTR
> EXEC (@SQLSTR)
>
> GO
>
> I can run this fine from SQL Server becuase I have admin rights, but when
> I
> run this from within my ASP.Net app with the following code, I get the
> following error message.
>
> DsIndex1.Tables("spQueryActivitiesWithIndex").Clear()
>
> daspQueryActivitiesWithIndex.Fill(DsIndex1,
> "daspQueryActivitiesWithIndex")
>
>
>
> Login failed for user '(null)'. Reason: Not associated with a trusted SQL
> Server connection.
> Description: An unhandled exception occurred during the execution of the
> current web request. Please review the stack trace for more information
> about the error and where it originated in the code.
>
> Exception Details: System.Data.SqlClient.SqlException: Login failed for
> user
> '(null)'. Reason: Not associated with a trusted SQL Server connection.
>
> I am new to ASP.NET so any help would greatly be apreciated.
>
>
>
>
>
>
>
>
>
>
>
>
>
Are all your drivers up to date? click for free checkup

Author
28 Dec 2005 7:23 PM
Jay Pemberton
Thank you for your prompt reply. I am sorry that I am nieve, but can you
provide links to the steps to add ASPNET user to SQL Server/Database?

Thanks

--
Sent via .NET Newsgroups
http://www.dotnetnewsgroups.com
Author
29 Dec 2005 3:17 PM
Jay Pemberton
I went into SQL Server and tried to add the ASPNET user from my local
machine, but it gave me an error saying Unknown User/Group, so do I need
to have dotnet installed on the SQL Server so that I can use the ASPNET
account there? Is there anything that I have to do on the application
side to facilitate using the ASPNET account besides changing the
machine.config file,  I tried that to no avail.  Any additional help
would be appreciated.

--
Sent via .NET Newsgroups
http://www.dotnetnewsgroups.com
Author
29 Dec 2005 5:50 PM
Mr Newbie
This is a Bultin Account so it will be something like  BUILTIN\ASPNET

--
Best Regards

The Inimitable Mr Newbie  º¿º
Show quoteHide quote
"Jay Pemberton" <jpember***@psc.state.wv.us> wrote in message
news:ezQ2vrIDGHA.748@TK2MSFTNGP12.phx.gbl...
>I went into SQL Server and tried to add the ASPNET user from my local
> machine, but it gave me an error saying Unknown User/Group, so do I need
> to have dotnet installed on the SQL Server so that I can use the ASPNET
> account there? Is there anything that I have to do on the application
> side to facilitate using the ASPNET account besides changing the
> machine.config file,  I tried that to no avail.  Any additional help
> would be appreciated.
>
> --
> Sent via .NET Newsgroups
> http://www.dotnetnewsgroups.com
Author
29 Dec 2005 6:06 PM
Jay Pemberton
I looked at the SQL Server through enterprise manager and tried to add a
user and did a seach for ASPNET and it didnt find a user called
BUILTIN\ASPNET, so does that mean that it dotnet isn't installed on the
SQL Server?

--
Sent via .NET Newsgroups
http://www.dotnetnewsgroups.com
Author
29 Dec 2005 6:07 PM
Jay Pemberton
I looked at the SQL Server through enterprise manager and tried to add a
user and did a seach for ASPNET and it didnt find a user called
BUILTIN\ASPNET, so does that mean that it dotnet isn't installed on the
SQL Server?

--
Sent via .NET Newsgroups
http://www.dotnetnewsgroups.com
Author
29 Dec 2005 11:04 PM
Mr Newbie
That is possible, but more likely you have not found the account yet.
Alternatively, it may be NT Authority\Network Service

--
Best Regards

The Inimitable Mr Newbie  º¿º


Show quoteHide quote
"Jay Pemberton" <jpember***@psc.state.wv.us> wrote in message
news:u0OjtKKDGHA.1268@TK2MSFTNGP12.phx.gbl...
>I looked at the SQL Server through enterprise manager and tried to add a
> user and did a seach for ASPNET and it didnt find a user called
> BUILTIN\ASPNET, so does that mean that it dotnet isn't installed on the
> SQL Server?
>
> --
> Sent via .NET Newsgroups
> http://www.dotnetnewsgroups.com

Bookmark and Share