jeremypollack
2007-03-21 18:41:31 UTC
Hey all,
Trying to do something simple here. I created a catalog for my site,
and am trying to query it. Generally, querying seems to work, but the
one thing I cannot get it to do is retrieve characterizations.
Yes, I did go to Catalog->Properties->Generation, turn off "Inherit
above settings from service" and turn on "Generate abstracts"
Yes, I have restarted the service and done a Rescan (Full) on all of
my indexed directories.
Here is my code :
protected void btnSearch_Click(object sender, EventArgs e)
{
lblOut.Text = "";
OleDbConnection connection = null;
OleDbCommand command = null;
OleDbDataReader reader = null;
string searchText = txtSearch.Text.Replace("'", "''");
connection = new OleDbConnection();
connection.ConnectionString = "Provider=MSIDXS; Data Source=
\"Babble\";";
connection.Open();
command = connection.CreateCommand();
command.CommandText = "select * from WEBINFO where
FREETEXT(Contents, '" + searchText + "') order by rank desc ";
command.CommandType = CommandType.Text;
reader = command.ExecuteReader();
while (reader.Read())
{
lblOut.Text += ((string)reader["path"]) +
((string)reader["filename"]) + " : " +
((string)reader["characterization"]) + "<br/><br/>";
}
reader.Dispose();
connection.Dispose();
}
When I click the button to do a search, I get the following error on
the line where I write the output to lblOut:
Unable to cast object of type 'System.DBNull' to type 'System.String'.
(and yes, this is test code, which is why I'm not doing any validation
checks)
Anybody know what I could be doing wrong?
--Jeremy
Trying to do something simple here. I created a catalog for my site,
and am trying to query it. Generally, querying seems to work, but the
one thing I cannot get it to do is retrieve characterizations.
Yes, I did go to Catalog->Properties->Generation, turn off "Inherit
above settings from service" and turn on "Generate abstracts"
Yes, I have restarted the service and done a Rescan (Full) on all of
my indexed directories.
Here is my code :
protected void btnSearch_Click(object sender, EventArgs e)
{
lblOut.Text = "";
OleDbConnection connection = null;
OleDbCommand command = null;
OleDbDataReader reader = null;
string searchText = txtSearch.Text.Replace("'", "''");
connection = new OleDbConnection();
connection.ConnectionString = "Provider=MSIDXS; Data Source=
\"Babble\";";
connection.Open();
command = connection.CreateCommand();
command.CommandText = "select * from WEBINFO where
FREETEXT(Contents, '" + searchText + "') order by rank desc ";
command.CommandType = CommandType.Text;
reader = command.ExecuteReader();
while (reader.Read())
{
lblOut.Text += ((string)reader["path"]) +
((string)reader["filename"]) + " : " +
((string)reader["characterization"]) + "<br/><br/>";
}
reader.Dispose();
connection.Dispose();
}
When I click the button to do a search, I get the following error on
the line where I write the output to lblOut:
Unable to cast object of type 'System.DBNull' to type 'System.String'.
(and yes, this is test code, which is why I'm not doing any validation
checks)
Anybody know what I could be doing wrong?
--Jeremy