I'm looking at integrating WDS functionality with an existing application and have been trying to call the ExecuteQuery from VB6 but am having problems.
Does anyone else have some example code that they've managed to get working
I've worked out that passing empty strings seems to case issues and am passing null references instead but am getting some errors raised ("Inv. Proc. Call").
This is for a small quick research project to decide between WDS and GDS so any suggestions would be very gratefully accepted!
Many Thanks,
John

WDS Query from VBScript or COM
beedub
My problems with this type of WDS project actually tipped me into upgrading from my tried-and-trusted VB6 into VB.NET (free as Visual Studio Express). I did get some success with VB6, though, so here's my code:
Public Function WDS_search(QueryText As String, sortfield As String, sortorder As Boolean)
Dim s As New WDSQuery.SearchDesktop
Dim rsLocal As ADODB.Recordset
Dim cols As String ' These are the cols that I wanted to display
cols = "FileName,DisplayFolder,DocAuthor,Create,PrimaryDate,Write,Size,FileExt,FileExtDesc,Rank,DocTitle,Directory,URL,Characterization"
If sortorder = True Then sortfield = sortfield & " DESC"
Set rsLocal = s.ExecuteQuery(QueryText, cols, sortfield, "Contains(PerceivedType,'email OR document OR folder')")
If Not (rsLocal.BOF And rsLocal.EOF) Then
WDS_search = rsLocal.GetRows
Else
WDS_search = Null
End If
Set rsLocal = Nothing
Set s = Nothing
End function
You must add a reference to the WDS dll into your project ("Windows Desktop Search Query Namespace"), and also a ref to ADO.
Call this function and you get back an array with the results of the query. You can scan through the array to get the results. It would be nicer if it just returned the recordset object but I couldn't make that work (until I moved up to a .NET version).
Ayyappan
Teacake,
Many thanks for that, I'd been playing with some of the other DLLs but had not tried that one.
I'll have a play with the code now!
John
Dylan Beattie
I believe this has to do with a bug in our API. What version of WDS are you trying this against Have you tried the 2.6 or 2.6.5 (Beta) versions
Unfortunately those might not help you, but it's worth a shot. Our new SDK PM started this week and should be working on getting an updated SDK out the door that might help with these kinds of problems.
GiovanniP
Brandon,
Thanks for getting back to me, I look forward to any more developments!
I'll try and wrap something up from the examples in the SDK for the moment.
John
ZMT
Glad to see that you've made it work OK. Now, what I really want to do is run it through an ASP or ASP.NET front end, but whenever I try to run this as part of a ASP or ASPX page it throws an error. I suspect that it might be that the IUSR account does not have the necesary permissions, but I gave it full access to the c: drive and it still complains. I can drop the results into a web page if I run the script client side, so there's no problem with the programming side, but as soon as I try and run it server side then it fails. In particular, I get this error from the IIS:
Unable to cast COM object of type 'Microsoft.Windows.DesktopSearch.Query.SearchDesktopClass' to interface type 'Microsoft.Windows.DesktopSearch.Query.ISearchDesktop'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{A227843C-1D92-48BC-AED6-DCA566F1790E}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).
Any clues for dealing with this would be much appreciated. I really want an ASP or ASP.NET front end for my queries.
Mohit Gogia
Hi All,
We're still working on seeing whether or not we can get some answers for you.
Thanlks for your patience.
Bill Connors
Program Manager, Windows Desktop Search - Communities
grandcanary
We're actually bringing on a new team member to focus specifically on these kinds of issues. I will make sure he's aware of these requests. I know it's not the answer you want (nor the answer I want to give), but with any luck we'll be able to address this relatively soon.
gdf
rgparkins
Knocked up a small sample, sorry for the code, it's quick and dirty so error handling is on the 'light' side...
We use Janus grid, so I've used that, but you should be able to use any grid that can be manually populated as the data is in an array.
Set the Janus to unbound datamode and add a reference as teacake.the.cat said above. Thanks again for his code which this is based on.
(sorry, formatting is rubbish)
Option Explicit
Private mDataBuffer As Variant
Public Function WDS_search(QueryText As String, sortfield As String, sortorder As Boolean) As Boolean
On Error GoTo WDS_search_eh
Dim s As New WDSQuery.SearchDesktop
Dim rsLocal As ADODB.Recordset
Dim cols As String ' These are the cols that I wanted to display
cols = "FileName,DisplayFolder,DocAuthor,Create,PrimaryDate,Write,Size,FileExt,FileExtDesc,Rank,DocTitle,Directory,URL,Characterization"
If sortorder = True Then sortfield = sortfield & " DESC"
Set rsLocal = s.ExecuteQuery(QueryText, cols, sortfield, "Contains(PerceivedType,'email OR document OR folder')")
If Not (rsLocal.BOF And rsLocal.EOF) Then
mDataBuffer = rsLocal.GetRows
Else
Err.Raise 999, "WDS_Search (" & QueryText & ")", "Query returned nothing"
End If
WDS_search = True
Exit Function
WDS_search_eh:
MsgBox "Failed to search" & vbCrLf & Err.Description, vbCritical
WDS_search = False
End Function
Private Sub Command2_Click()
If WDS_search(txtSearch.Text, "Rank", True) Then
GridEX1.ItemCount = UBound(mDataBuffer, 2)
Else
GridEX1.ItemCount = 0
End If
End Sub
Private Sub Form_Load()
Dim colTemp As JSColumn
GridEX1.Columns.Clear
Set colTemp = GridEX1.Columns.Add("File Name", jgexText, jgexEditTextBox, "FileName")
colTemp.Width = 3000
Set colTemp = GridEX1.Columns.Add("Document Type", , , "DocumentType")
colTemp.Width = 3000
Set colTemp = GridEX1.Columns.Add("Size", , , "Size")
colTemp.Width = 600
colTemp.SortType = jgexSortTypeNumeric
GridEX1.ItemCount = 0
End Sub
Private Sub GridEX1_UnboundReadData(ByVal RowIndex As Long, ByVal Bookmark As Variant, ByVal Values As GridEX20.JSRowData)
Values(1) = mDataBuffer(0, RowIndex)
Values(2) = mDataBuffer(8, RowIndex)
Values(3) = mDataBuffer(6, RowIndex)
End Sub
jmodares.com
Section Z
I'm not really a VB6 or VBScript expert, but I think this may in fact be a limitation of our current Beta SDK.
We're working to release a greatly improved SDK, including improved APIs and documentation. Unfortunately, I can't share (nor do I have) a specific timeline for that release.
bobmarble
ahossain
Hi All,
Were Brandon's comments helpful and if so, could you please mark this as answered
Thanks,
Bill Connors
Program Manager, Windows Desktop Search - Communities
Waqar Azeem
Hi All,
Sorry for the delay - still working this.
Thanks,
Bill Connors
Program Manager, Windows Desktop Search - Communities