jil-ice-cool

Hi ,

I have access database table with one column as oleobject datatype.where a word file is stored previously.

Now i want to export those into physical files as word document

using C# .i have used filestram aobject but it is storing as binary data.it is not storing as excat data.Below is my code

String strConn = @"Provider = Microsoft.Jet.OLEDB.4.0;Data Source = C:\f1.mdb;";

OleDbConnection conn = new OleDbConnection(strConn);

Byte[] byPicture;

String strCmd = "Select cv From contacts where ID=-2139550156";

OleDbCommand cmd = new OleDbCommand(strCmd, conn);

try

{

conn.Open();

byPicture = (Byte[])cmd.ExecuteScalar();

conn.Close();

FileStream fs = new FileStream("f1.doc",FileMode.OpenOrCreate,FileAccess.Write);

fs.Write(byPicture,0,System.Convert.ToInt32(byPicture.Length));

fs.Seek(0, SeekOrigin.Begin);

fs.Close();

}

can you give some tips

Cheers,

Jil



Re: Visual C# General C# And File System And Access

TaylorMichaelL

AFAIK you can't use ExecuteScalar to do what you want. You should instead use a DataReader to stream the file across. You can then stream it into a file. Here is a MS KB article on how to do it: http://support.microsoft.com/kb/309158 You'll need to make a few changes to get it to work with your DB.

Michael Taylor - 5/19/07

http://p3net.mvps.org