Indexing Service empty filename property - vb.net

I'm using the Windows Indexing Service for the first time and I need to return the doctitle and filename from the query.
My query is;
select doctitle, filename, vpath, rank, characterization from scope() where FREETEXT(Contents, '" & searchText & "') order by rank desc
I setup a fairly basic catalogue just pointing to a folder. I'm using this code from a website, the files are on the local machine and authentication shouldn't be a problem.
My search returns results but nothing in the filename property. The doctitle is populated but nothing else.
Thanks,
Mike

I know it's been a few months since this has been answered, but I'm currently using WIS on Windows Server 2008 R2 using C# and came across this on a search. Sometimes I can't take no for an answer, so I had scoured the internet and came up with this solution.
I'm sure you can convert the code as necessary, but...
You'll have to install the Windows Server 2003 File Services Indexing Service from the Server Manager's Roles.
For the catalog properties, I disabled the Inheritable Settings and set the WWW Server appropriately. I also generated 250 character abstracts to be stored in the Characterization column.
When I set up my catalog, I included/excluded certain folders of my web site's directory (include the site root) and when I queried it, I used the below SQL statement:
EDIT: Note the use of FREETEXT(Filename, '\""+q+"\"')) to query the name of the file
String fileTypes = "\".aspx\" OR \".doc*\" OR \".xls*\" OR \".ppt*\" OR \".txt\" OR \".pdf\" OR \".rtf\"";
String q = query.Text.Replace("'", "''");
sSqlString = "SELECT Filename, DocTitle, Size, VPath, Path, Rank, Write, Contents, Characterization ";
sSqlString += "FROM SCOPE() ";
sSqlString += "WHERE (CONTAINS(Contents, '\""+q+"\"') ";
sSqlString += "OR FREETEXT(Filename, '\""+q+"\"')) ";
sSqlString += "AND CONTAINS(Filename, '"+fileTypes+"') ";
sSqlString += "ORDER BY rank DESC, write DESC";
I create my connection using the using statement:
using(OleDbConnection conn = new OleDbConnection("Provider=MSIDXS.1;Data Source='"+catalog+"'"))
{
//your connection and data collection code here
}
One of the issues that I have run into is with certain filetypes. If the document creator didn't include a document title in their MS Office product, you won't get the DocTitle. If the pdf doesn't have any recognizable text in it and the document properties are not filled out, the docTitle and Content will be empty. The way I look at it, is if the business doesn't make their files 508 compliant, they won't show up in the results properly.
Here's a quick snippet of the ListView template that I am using.
<ItemTemplate>
<h3><%# Eval("DocTitle").ToString().Trim() == "" ? Eval("Filename").ToString().Split('.')[0] : ProperCase(Eval("DocTitle").ToString()) %></h3>
<p><span style="color:#0083be;">
<%# Request.ServerVariables["HTTP_HOST"].Length+vFilePath(Eval("Path")).Length > 100 ? (Request.ServerVariables["HTTP_HOST"]+vFilePath(Eval("Path"))).Substring(0,100)+"..." : Request.ServerVariables["HTTP_HOST"]+vFilePath(Eval("Path")) %></span><br />
<span style="color:#4d4e53"><%# String.Format("{0:MMMM dd, yyyy}",Eval("Write")) %> - </span>
<%# Eval("Characterization").ToString().Trim() == "" ? "..." : Eval("Characterization").ToString().Length == 250 ?
Eval("Characterization").ToString().Substring(0,250)+"..." : Eval("Characterization")%>
</p>
</ItemTemplate>
Since the docTitle in my case is used for the results header, I figured that if it's empty, I can take that empty string and replace it with the filename, minus the extention.
When making the query, make sure that you also properly use your meta tags using the keywords and description. This and the static content on the .aspx pages does get read by WIS. You'll note my use of Characterization to retrieve the contents.
This link provides instructions on setting up the W2k8 WIS along with vb.net code.
This link is a good source for the multitude of properties that can be queried and/or displayed.

I found the answer in this article;
http://support.microsoft.com/kb/954822
You cannot index Internet Information Services (IIS) Web sites in
Windows Server 2008 because of the design changes that were made to
IIS 7.0.
The successor or the Indexing Service is Windows Search.
Windows Search Wiki
Looks like I'm going to have to change the site to use Windows Search.

Related

Volusion's generic SQL folder, functionality

I found this response very helpful
How to write join query in Volusion API
What I'm looking for is a way to add my own .SQL and .XSD files to the /vspfiles/schema/Generic folder and be able to pass parameters to it. Does anyone know if that's possible.
A very basic example of the SQL would be something like this...
select * from Orders where order_id = "-ORDERID-"
...and I'd be able to pass in the "-ORDERID-" as a variable.
Or even better the SQL file would just be this "-SQL-" and I could pass in the entire SQL string myself. Thanks!
Thanks user357034 for getting me here (I'd "up" your answer but I'm new and don't have any reputation). I wanted to post the code I used in case others run into this. And also get any feedback if you see anything that looks goofy here.
First, I created an ASP file like so
Dim orderid
Dim status
orderid = Request.QueryString("orderid")
status = Request.QueryString("status")
sql = " update Orders " & _
" set OrderStatus = '" + status + "' " & _
" where Orderid in (" + orderid + ") " ;
set fs=Server.CreateObject("Scripting.FileSystemObject")
set f=fs.OpenTextFile(Server.MapPath("./MY_FILE.sql"),2,true)
f.WriteLine(sql)
f.Close
set f=Nothing
set fs=Nothing
I FTPed that up to the "generic" folder on Volusion.
Next, in PHP, I call this file, similar to this...
$asp = file("http://MY_SITE/v/vspfiles/schema/generic/MY_FILE.asp?
orderid=11,12&status=Processing");
foreach ( $asp as $line )
{
echo ($line);
}
NOTE: I already FTPed an XSD file to the same folder with the same name, like MY_FILE.xsd.
And finally, I make a web service call to my service, like this...
$url = "http://MY_SITE/net/WebService.aspx?
Login=XXXX&EncryptedPassword=YYYYY&API_Name=Generic\MY_FILE"
Works great. I go into the Volusion admin site, look at the Orders 11 and 12, and they were updated. I'm using this method for several areas in Volusion where their API is lacking. Thanks!
While technically one could pass in text comprised of a complete SQL query, however I would strongly caution against such practice as it would open up your site to malicious activity and/or possible security issues. I would limit the scope to a specific query and only allow one or more parameters to be used.
To accomplish this you have to create an custom ASP page in Volusion that would gather the parameters from the user, in your case "order id" and then insert them into the set SQL query, write that SQL query as a text file to the server in the correct location as shown in https://stackoverflow.com/a/29134928/357034 and then execute the query. All this is done in the custom ASP page.
UPDATE: If you just want a simple order id query with all fields returned you don't even have to use the the SQL method as Volusion already has a built in method to return this data. You just have to use a custom ASP page to insert the order id parameter and then execute the URL with the parameter attached. In your ASP page you would insert the order id in place of the xxxxx
http://www.yoursiteurl.com/net/WebService.aspx?Login=name#yoursiteurl.com&EncryptedPassword=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxC&EDI_Name=Generic\Orders&SELECT_Columns=*&WHERE_Column=o.OrderID&WHERE_Value=xxxxx

MS SQL Server 2012 returning blank text?

I execute this inside MS SQL Server Management Studio:
SELECT TOP 2 * FROM searchdb.dbo.tblnames;
I get back two posts with full information.
When I execute the same on a webpage I however get all information except for text, which is blank.
The type of the text columns in the database are:
ntext
The connection string I'm using:
Driver={SQL Server};Server=localhost;Database=searchdb;Uid=myuser;Pwd=mypass;
I've also tried with:
Driver={SQL Server Native Client 11.0};Server=localhost;Database=searchdb;Uid=myuser;Pwd=mypass;
Getting the same result. I don't know the difference between "SQL Server" and "SQL Server Native Client 11.0", just that "SQL Server" has a newer date in the list of ODBC Data Sources.
What's going on? Why is it returning blank text? How do I fix this?
Edit: Here is the code I'm using on the ASP web pages:
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "Driver={SQL Server};Server=localhost;Database=searchdb;Uid=myuser;Pwd=mypass;"
Set RecSet = Conn.Execute("SELECT TOP 2 * FROM tblnames;")
Response.Write "ID: "& RecSet("ID") &"<br>"
Response.Write "Name: "& RecSet("name") &"<br>"
Response.Write "Mark: "& RecSet("mark") &"<br>"
RecSet.MoveNext
Response.Write "ID: "& RecSet("ID") &"<br>"
Response.Write "Name: "& RecSet("name") &"<br>"
Response.Write "Mark: "& RecSet("mark") &"<br>"
Set RecSet = Nothing
Both the ID and Mark columns have "int" data type and show up fine, while the "name" column is blank.
Edit 2:
Users with less than 10 reputation can't answer their own question
for 8 hours after asking. You can answer 3/15/2014 4:16:50 AM. Until
then please use comments, or edit your question instead.
It's dumb that you have to make an account on stackoverflow (didn't have to before), and that you can't answer your own questions on a new account. And I hope some mod doesn't edit this post. If things are wrong with your system it's important that people can point it out.
Anyways, here is the answer:
Self-answered:
I changed my connection string to:
Provider=SQL Server Native Client 11.0;Server=localhost;Database=searchdb;Uid=myuser;Pwd=mypass;
Now everything works fine.
I have no idea why it didn't work correctly when I used that one as "Driver" but whatever. Note that just "Provider=SQL Server" didn't work at all, while "Driver={SQL Server}" worked exactly the same as "Driver={SQL Server Native Client 11.0}" (that is, with blank text).
No idea how Provider is different than Driver. "Provider" isn't even mentioned anywhere in Control Panel > Administrative Tools > ODBC Data Sources.
After some testing it seems like both Driver and Provider is just as fast as each other too, so there's no benefit from using Driver, it is just broken.
It looks like changing your query to use a column list, rather than the asterisk, could take care of the issue. Also, I read that your ntext field should be the last column in your list. Seems strange, but it's worth a shot.
Resources:
http://databases.aspfaq.com/database/how-do-i-deal-with-memo-text-hyperlink-and-currency-columns.html
SQL Server text column affects results returned to classic ASP
EDIT:
You also might try converting the ntext to an nvarchar in your sql statement.
SELECT TOP 2 ID, Mark, CONVERT(NVARCHAR(MAX), Name) [Name] FROM tblNames

Unknown table name in VB.net using microsoft Access?

Sorry if my subject isn't clear enough because I don't know how else to put. So here's the thing, I need to debug and test a VB.NET windows application for hotel management system. I'm quite new to VB.NET, so there is a few lines of database query that I didn't get. There is a few lines such as :
Com.CommandText = "Select * from QRoom Order by RoomNo"
or
Com.CommandText = "Select Floor from QRoom where RoomNo=" & cbo.Text & ""
as you can see the table name there is QRoom but when I check within the Access database, there is no table name QRoom. But if I change the table name to the one that us in the database(which is my case, it is TblRoom), then there will be errors. So I didn't get why is that. Any help is appreciated.
p/s : the guy who wrote this code is unreachable st the moment so I cannot directly ask him. :(

Create a Crystal Report with dynamic tables at runtime

Hello I'm planning an application that is basically a reporting front-end for a database (proprietary Pervasive SQL) using an ODBC dsn-less connection string.
I am able to create the dataset in Visual Studio and link up the report(s) to the app. However in real world usage, the location of the database will be different per user. That is not the main problem. I overcame that with the connection string that allows you to set the location of the database path.
Here's the kicker...
The name of the tables that I want to read from are prefixed with a unique filename (actually the same name I mentioned above). I need crystal to re-map the table names at runtime. Just the table name prefixes really. The fields and names of the fields will not change.
Any ideas on where I should look for writing this block? I am using VS2010 & C# if that helps. I think thee should be some sort of class files that come with Crystal that can do some runtime reflection to get/set the table names?
Any thoughts would be welcome and appreciated.
Rob
Edit: I found some documents link that has API docs and other support. I will be studying them. They are all .chm files (Windows help files) so there is no "online" docs to search for.
Add a Crystal reportViewer change the name to objReport
add a public function ShowReport()
public void ShowReport(ReportDocument objReport)
{
Cursor.Current = Cursors.WaitCursor;
objReport.SetDatabaseLogon("", "dbpassword");
cRep.ReportSource = objReport;
this.Show();
Cursor.Current = Cursors.Default;
}
And Call it from anywhere in your application
ds = GetDataInDataSet();//fILL DataSet with your data
rptPSummary objRpt = new rptPSummary();
objRpt.SummaryInfo.ReportComments = "Have a nice day";
objRpt.SummaryInfo.ReportTitle = "Purchase Summary Report from " + sDate.ToString("dd/MM/yyyy") + " to " + eDate.ToString("dd/MM/yyyy");
objRpt.SetDataSource(ds);
frmReportView frmRpt = new frmReportView();
frmRpt.Text = objRpt.SummaryInfo.ReportTitle;
frmRpt.MdiParent = this;
frmRpt.ShowReport(objRpt);

can't delete site columns that aren't referenced

I just created a couple of site columns and content types that reference them through VS2010. I updated one of the fields and then tried to redeploy, but after retracting, deploy failed because the site columns previously created were still there. I tried to delete them manually from the UI, and got an alert box with this message:
Site columns which are included in content types cannot be deleted.
Remove all references to this site
column prior to deleting it.
I dug around in SharePoint Manager and didn't find any references, so I used powershell to enumerate all the content types and lists looking for references to my site columns and found nothing.
I tried to delete using PowerShell like this:
$web.Fields.Delete("StartTime")
which resulted in this error:
Exception calling "Delete" with "1" argument(s): "Site columns which are included in
content types or on lists cannot be deleted. Please remove all instances of this site
column prior to deleting it."
At line:1 char:19
+ $web.Fields.Delete <<<< ("StartTime")
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException
Finally, a simple inspection of the columns in PowerShell shows the following:
Title Id CanBeDeleted ParentList Sealed ListsFieldUsedIn
----- -- ------------ ---------- ------ ----------------
Start Time OBE 6fa0d85b-9af1-408b-835f-d4c66536... True False {}
Time Tracker Tags 92bc866b-0415-45f0-b431-d4df69c4... True False {}
I'm experienced with MOSS 2007 and new to SP2010, but I've never seen this happen before. Anyone have any hints?
Your need to find and remove both the content types that use the site column and also any lists or libraries that use the site column you are trying to delete. Use PowerShell to get the site column object using something like this:
$column = $web.Fields[“Column Display Name”]
Then find all the places where it is used, using something like this:
$column.ListsFieldUsedIn()
which spits out two GUIDs -- the WebID and ListID -- of every place that uses this content type.
Below is a PowerShell script that loops over all the list GUIDs returned from ListFieldUsedIn() and then finds the subweb and list matching that GUID and prints out list name and subweb URL for each usage :
$site = Get-SPSite "http://sharepoint"
$rootweb = $site.rootweb
$siteColumnToRemove = "Column Display Name”
$sc = $rootweb.Fields[$siteColumnToRemove]
if ($sc)
{
write-host " Found Site Column '" $sc.Title "' in gallery" -ForegroundColor Gray
foreach( $listusage in $sc.ListsFieldUsedIn() )
{
$listID = $listusage.ListID
foreach ($subweb in $site.allwebs)
{
foreach ($list in $subweb.lists)
{
if ($list.ID -eq $listID)
{
write-host " Site Column '" $sc.Title "' used in list '" $list.Title "' in site '" $subweb.Url "'" -BackgroundColor Yellow -ForegroundColor Black
}
}
}
}
}
Happens to SharePoint 2010 too. Try looking at:
$field.AllowDeletion = $TRUE
$field.Update()
When I set that, seemed to work. Now I just can't replicate it, in order to prove my point. Typical.
I had this same problem and was able to delete using SharePoint Designer - not sure if anyone can validate this works for them.
It's been a while, and I've long since moved on from this problem, but I think that the final answer was that there were content types relying on a particular site column that weren't picked up by SPM.
I think once I retracted everything custom from the site, I was able to delete normally.
My guidance is that you should never delete a site column once it's in use. I've seen site collections become completely unusable because of issues trying to delete site columns or content types.
If you no longer need the site column, just hide it.