我正在开发一个基于Windows搜索的搜索模型,特别是以下链接中的Dsearch示例http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=7388 在查询文件夹下。
问题是,我需要将此搜索方法作为我需要在asp.net应用程序中使用的WCF服务。正如我已经发现问题出在OleDbConnection对象中 -which通过windows应用程序连接到索引器提供程序 - 。
在调用
时, IErrorInfo.GetDescription失败且E_FAIL(0x80004005)异常OleDbDataReader.read()
我的问题是OleDbConnection可以与WCF服务一起使用吗?
代码:
// Generate SQL from our parameters, converting the userQuery from AQS->WHERE clause
string sqlQuery = queryHelper.GenerateSQLFromUserQuery(userQuery);
// --- Perform the query ---
// create an OleDbConnection object which connects to the indexer provider with the windows application
System.Data.OleDb.OleDbConnection conn = new OleDbConnection(queryHelper.ConnectionString);
// open it
conn.Open();
// now create an OleDB command object with the query we built above and the connection we just opened.
OleDbCommand command = new OleDbCommand(sqlQuery, conn);
// execute the command, which returns the results as an OleDbDataReader.
OleDbDataReader WDSResults = command.ExecuteReader();
while (WDSResults.Read())
{
nResults++;
// col 0 is always our path in display format
string path = WDSResults.GetString(0);
if (fScope)
{
// if it is relative to the current directory, then just show the relative part of the path
path = path.Substring(Directory.GetCurrentDirectory().Length + 1);
}
if (fDisplayContents)
{
// output the file to our WDSResult file to build the list of files for input to findstr
fileList.Add(path);
}
else
{
List<string> val = new List<string>();
// if they have a custom sort column
if ((fBare == false) && (sortCol != "System.ItemPathDisplay"))
{
// then get it
val[0] = WDSResults.GetValue(1).ToString();
// and output it
return val[0];
}
return val[0] + path;
// output the path
//Console.WriteLine(path);
}
}
WDSResults.Close();
conn.Close();
修改 我在控制台应用程序和WCF服务中都有完全相同的查询
CommandText = "SELECT \"System.ItemPathDisplay\" FROM \"SystemIndex\" WHERE CONTAINS(*,'\"soa*\"',1033) AND scope='file:D:\\4Project' ORDER BY System.ItemPathDisplay ASC"
CommandText = "SELECT \"System.ItemPathDisplay\" FROM \"SystemIndex\" WHERE CONTAINS(*,'\"soa*\"',1033) AND scope='file:D:\\4Project' ORDER BY System.ItemPathDisplay ASC"