473,385 Members | 1,798 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Syntax Problem in Code using SCOPE() function

Trying to use Microsoft Indexing Service.

Here is my code using SQL Query Analyzer, which works perfectly.

SELECT * FROM
OPENQUERY(FileSystem,
'SELECT RANK, FileName, Characterization
FROM SCOPE(''"/ASPNetDemo/Resumes"'')
WHERE FREETEXT(''Baione'') > 0
ORDER BY RANK DESC' )

but... when I put this code in the script in my ASPX page, apparently the
syntax does not work. The following is all of my code.

Sub btnSearch_Click(ByVal s As Object, ByVal e As EventArgs)
Dim conMyData As SqlClient.SqlConnection
Dim strSearch As String
Dim cmdSearch As SqlClient.SqlCommand
Dim dtrSearch As SqlClient.SqlDataReader
Dim x As String
x = "'/ASPNetDemo/Resumes'"
conMyData = New
SqlClient.SqlConnection("Server=Localhost;UID=sa;P WD=test;Database=Pubs")
strSearch = "SELECT * FROM " & _
"OPENQUERY(FileSystem, " & _
"'SELECT RANK, FileName, VPath, Characterization " & _
"FROM SCOPE(''" & "\ASPNetDemo\Resumes" & "'') " & _
"WHERE FREETEXT(''" & txtSearchPhrase.Text & _
"'') > 0 " & _
"ORDER BY RANK DESC' )"

cmdSearch = New SqlClient.SqlCommand(strSearch, conMyData)
conMyData.Open()
Try
dtrSearch = cmdSearch.ExecuteReader()
lblResults.Text = "<ul>"
While dtrSearch.Read
lblResults.Text &= "<li> (" & dtrSearch("RANK") / 10 & "%) "
lblResults.Text &= "<a href=""" &
dtrSearch("VPath").ToString()
lblResults.Text &= """>"
lblResults.Text &= dtrSearch("FileName") & "</a><br>"
lblResults.Text &= dtrSearch("Characterization")
lblResults.Text &= "<p>"
End While
Catch ex As Exception
lblResults.Text = "Please rephrase your query"
End Try
conMyData.Close()
End Sub

Any help in pointing out the correct syntax using the SCOPE function would
be greatly appreciated.

Thanks

Jul 21 '05 #1
2 1527
"=?Utf-8?B?VW1wdHk=?=" <Um***@discussions.microsoft.com> wrote in
news:69**********************************@microsof t.com:
Trying to use Microsoft Indexing Service.

Here is my code using SQL Query Analyzer, which works perfectly.

SELECT * FROM
OPENQUERY(FileSystem,
'SELECT RANK, FileName, Characterization
FROM SCOPE(''"/ASPNetDemo/Resumes"'')
WHERE FREETEXT(''Baione'') > 0
ORDER BY RANK DESC' )

<code snipped>

conMyData = New
SqlClient.SqlConnection("Server=Localhost;UID=sa;P WD=test;Databas
e=Pubs")
strSearch = "SELECT * FROM " & _
"OPENQUERY(FileSystem, " & _
"'SELECT RANK, FileName, VPath, Characterization " & _
"FROM SCOPE(''" & "\ASPNetDemo\Resumes" & "'') " & _
"WHERE FREETEXT(''" & txtSearchPhrase.Text & _
"'') > 0 " & _
"ORDER BY RANK DESC' )"


Umpty,

You have different slash characters in the VB code. I believe the /
character is required, not the \ character.

--
Hope this helps.

Chris.
-------------
C.R. Timmons Consulting, Inc.
http://www.crtimmonsinc.com/
Jul 21 '05 #2
Chris, this didn't work...

Thanks,
Umpty

"Chris R. Timmons" wrote:
"=?Utf-8?B?VW1wdHk=?=" <Um***@discussions.microsoft.com> wrote in
news:69**********************************@microsof t.com:
Trying to use Microsoft Indexing Service.

Here is my code using SQL Query Analyzer, which works perfectly.

SELECT * FROM
OPENQUERY(FileSystem,
'SELECT RANK, FileName, Characterization
FROM SCOPE(''"/ASPNetDemo/Resumes"'')
WHERE FREETEXT(''Baione'') > 0
ORDER BY RANK DESC' )

<code snipped>

conMyData = New
SqlClient.SqlConnection("Server=Localhost;UID=sa;P WD=test;Databas
e=Pubs")
strSearch = "SELECT * FROM " & _
"OPENQUERY(FileSystem, " & _
"'SELECT RANK, FileName, VPath, Characterization " & _
"FROM SCOPE(''" & "\ASPNetDemo\Resumes" & "'') " & _
"WHERE FREETEXT(''" & txtSearchPhrase.Text & _
"'') > 0 " & _
"ORDER BY RANK DESC' )"


Umpty,

You have different slash characters in the VB code. I believe the /
character is required, not the \ character.

--
Hope this helps.

Chris.
-------------
C.R. Timmons Consulting, Inc.
http://www.crtimmonsinc.com/

Jul 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
by: George Sakkis | last post by:
Is there a general way of injecting code into a function, typically before and/or after the existing code ? I know that for most purposes, an OO solution, such as the template pattern, is a cleaner...
1
by: Ken Fine | last post by:
I have a menu system that has nodes that can be opened or closed. In an effort to make my code more manageable, I programmed a little widget tonight that keeps track of the open/active item and...
4
by: Bobbak | last post by:
Hello All, I was wondering if it is possible to do this; I have a form that has number of text boxes that when a button is clicked it turns into combo boxes, simply by toggling the visibility to...
5
by: Filips Benoit | last post by:
Dear All, I'm looking for a function that does the same as the find-action in the code-window. Thanks, Filip
2
by: Umpty | last post by:
Trying to use Microsoft Indexing Service. Here is my code using SQL Query Analyzer, which works perfectly. SELECT * FROM OPENQUERY(FileSystem, 'SELECT RANK, FileName, Characterization FROM...
1
bartonc
by: bartonc | last post by:
You will be rewarded sooner than you think when you use docstrings to document your classes and functions. Whether you ever intend to publish your work or not, docstrings will help you in several...
1
by: Sonalisa48 | last post by:
Syntax for using a decode function to check a string size. sample query: (select text from Noteline where EnteringofHeading = 'BillingAddress1' and notenumber= (select note from OrderHeader where...
2
by: Will | last post by:
Hi, I need to handle blank values in a query calculation. I have 636 records at the moment but when I sum over these records the blank fields are not returned. I have looked around here and on...
2
myusernotyours
by: myusernotyours | last post by:
Hello everyone. I am using a C library from C++ code. The C library declares some function pointers using typedef, and then makes some variables using this function pointer as the type. Like: ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.