Ms Word ファイルのテキストをバイナリに変換してデータベースに保存する必要があります。ファイルと TrackRevisions も開くことができました。MS Word テキストをデータベースに保存し、それを取得して MS Word に表示するにはどうすればよいですか
1 に答える
1
ファイルの内容をbinary/varbinaryフィールドに保存できます(SQL Serverで許可される最大長は8000です)。
パラメータを使用して、データベースを挿入/更新します。ここにac#の例:
//reading the file content
FileStream s = new FileStream(filePath, FileMode.Open, FileAccess.Read);
byte[] buffer = new byte[s.Length];
s.Read(buffer, 0, s.Length);
s.Close();
//adding a row in the database
SqlCommand insertCommand = new SqlCommand("insertCommand into myTable (binaryField) values (@filedata)", youconnection);
insertCommand.Parameters.Add(new SqlParameter ("@filedata", buffer ));
insertCommand.ExecuteNonQuery();
于 2013-01-04T06:20:37.383 に答える