Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/316.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# FTS使用故障_C#_Sql Server 2008_Full Text Search - Fatal编程技术网

C# FTS使用故障

C# FTS使用故障,c#,sql-server-2008,full-text-search,C#,Sql Server 2008,Full Text Search,我由此创建了一个FTS 我有一个类型为varbinary(max)的列,我用MSWord文件(.doc)填充它,还有一个类型为word(由.doc填充)的列。 运行此脚本时,输出为空 SELECT name, content FROM tblWordFiles WHERE FREETEXT(content, '1'); 或 我的问题在哪里 噢! 我使用此代码填充数据库(c#) 您引用的是参数@c,因此将其作为文本值而不是参数值插入 请参阅:insert-into-tblWo

我由此创建了一个FTS 我有一个类型为varbinary(max)的列,我用MSWord文件(.doc)填充它,还有一个类型为word(由.doc填充)的列。 运行此脚本时,输出为空

SELECT 
    name,
    content
FROM tblWordFiles 
WHERE FREETEXT(content, '1');

我的问题在哪里

噢! 我使用此代码填充数据库(c#)


您引用的是参数@c,因此将其作为文本值而不是参数值插入

请参阅:
insert-into-tblWordFiles(type,content)值('doc','@c')

应为:
insert-into-tblWordFiles(type,content)值('doc',@c)

我不确定类型列是否包含“.”或“.doc”或“doc”

SELECT 
    name,
    content
FROM tblWordFiles 
WHERE contains(content, '1');
    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();
    }