FTS使用故障
问题描述:
我创建了一个FTS这article 我有一个类型的varbinary(最大),我填充了MSWord文件(.doc)和另一列字类型(填充.doc)的列, 。 当我运行此脚本,输出是空FTS使用故障
SELECT
name,
content
FROM tblWordFiles
WHERE FREETEXT(content, '1');
或
SELECT
name,
content
FROM tblWordFiles
WHERE contains(content, '1');
哪里是我的问题吗?
ooooooo! 我用这个代码来填充数据库(C#)
SqlConnection cn = new SqlConnection(@"Data Source=MJ;Initial Catalog=Test_word_binary;Integrated Security=True");
string command = "insert into tblWordFiles (type,content) values('doc','@c')";
SqlCommand cm = new SqlCommand(command, cn);
DialogResult dg = openFileDialog1.ShowDialog();
if (dg == DialogResult.OK)
{
// Create a new stream to load this photo into
System.IO.FileStream stream = new System.IO.FileStream(openFileDialog1.FileNames[0], System.IO.FileMode.Open, System.IO.FileAccess.Read);
// Create a buffer to hold the stream bytes
byte[] buffer = new byte[stream.Length];
// Read the bytes from this stream
stream.Read(buffer, 0, (int)stream.Length);
// Now we can close the stream
stream.Close();
cm.Parameters.Add("@c", SqlDbType.VarBinary).Value = buffer;
cn.Open();
cm.ExecuteNonQuery();
cn.Close();
}
答
你报价参数@c,所以其作为一个文本值,而不是参数的值插入。
参见:insert into tblWordFiles (type,content) values('doc','@c')
应该是:insert into tblWordFiles (type,content) values('doc',@c)
我不知道该类型的列是否包括 ''或不是,即'.doc'或'doc'
谢谢keeperOfTheSoul – 2009-09-02 12:57:44