Asp.net 通过WCF服务打开OLEDB连接
我正在构建一个基于windows搜索的搜索模型,特别是下面链接中的Dsearch示例 在查询文件夹下 问题是,我需要将此搜索方法作为我需要在asp.net应用程序中使用的WCF服务。我发现问题出在OleDbConnection对象中 -它通过windows应用程序连接到索引器提供程序- 调用时,它给出了IErrorInfo.GetDescription失败且E_失败(0x80004005)异常Asp.net 通过WCF服务打开OLEDB连接,asp.net,wcf,interop,oledb,windows-search,Asp.net,Wcf,Interop,Oledb,Windows Search,我正在构建一个基于windows搜索的搜索模型,特别是下面链接中的Dsearch示例 在查询文件夹下 问题是,我需要将此搜索方法作为我需要在asp.net应用程序中使用的WCF服务。我发现问题出在OleDbConnection对象中 -它通过windows应用程序连接到索引器提供程序- 调用时,它给出了IErrorInfo.GetDescription失败且E_失败(0x80004005)异常 OleDbDataReader.read() 我的问题是OLEDB连接能否用于WCF服务 代码: 有
OleDbDataReader.read()
我的问题是OLEDB连接能否用于WCF服务
代码:
有人建议,当您在YOUR或sql语句中键入保留字时,可能会发生这种情况。也许你需要逃避它?也许再添加一点代码,这样我们就可以看到命令、连接道具。。。
// 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();
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"