byte array size is 977kb when i try to store into ms access database its getting stored without error making the ms access database size 140kb(i know it uses different format to store so lesser kb)

But when i try retrieving the same code from ms access database and when i store it into temporary byte array i am getting only 25 bytes.

So where am i going wrong .
whats the code to store the full text contents into ms access database

Whats the code to retrieve the full contents if at all full contents is stored.

Have a look,

//Table: TestTable(Filename Text(40), FileContent(Ole Object)
            byte []bytes={22,222,33,44,55};
            OleDbConnection cn = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=c:\csnet\ConsoleApplication5\Database1.accdb;Persist Security Info=True");
            
            OleDbCommand cmd = new OleDbCommand("insert into TestTable values (@filename,@filecontent)", cn);
            cmd.Parameters.Add("@filename", OleDbType.VarChar, 40).Value = "file.gif";
            cmd.Parameters.Add("@filecontent", OleDbType.Binary, bytes.Length).Value = bytes;
            cn.Open();
            cmd.ExecuteNonQuery();
            cn.Close();

actually storing the byte array to access database is not a problem
its gets stored the only thing is when i try to retrieve the same byte array from access database i am getting only 25bytes

WHY IS THAT SO

Please show us your code that store/retrieve byte array.

FileStream fs = new FileStream("encrypted.txt", FileMode.Open);

            byte[] buff = null;
            BinaryReader br = new BinaryReader(fs);
            long numBytes = new FileInfo("encrypted.txt").Length;
            buff = br.ReadBytes((int)numBytes);

           mycon.Open();
           OleDbCommand cmd = new OleDbCommand("INSERT INTO song VALUES('1','" + buff + "')", mycon);
            cmd.ExecuteNonQuery();
            mycon.Close();
            fs.Close();
// above code is inserting part 

//below code is extracting part 
           byte[] temp = new byte[200000000];
           mycon.Open();

           OleDbCommand cmd = new OleDbCommand("select file from song", mycon);
           System.Data.OleDb.OleDbDataReader dr;
           dr = cmd.ExecuteReader();
           dr.Read();
           temp = (byte[])dr["file"]; //only 25 bytes i am getting
           int len = temp.Length; //25 length 

           FileStream fs = new FileStream(@"C:\Documents and Settings\SHREESHILA1\Desktop\dummy.txt", FileMode.Create);
           fs.Close();

           BinaryWriter br = new BinaryWriter(File.Open(@"C:\Documents and Settings\SHREESHILA1\Desktop\dummy.txt", FileMode.Open));


           br.Write(temp);

           //br.Write(temp);
           br.Close();

now check the code boss, i hope now u will be able to find the problem easily

waiting for your answer

First of all, I have noticed that you later reposted this problem you are having, which is not proper to do. I provided you with a reply in that repost about what I saw as a problem.

Secondly, see my comments regarding your posts below:

actually storing the byte array to access database is not a problem
its gets stored the only thing is when i try to retrieve the same byte array from access database i am getting only 25bytes

WHY IS THAT SO

In the above, you have made a FALSE assumption that you are correctly inserting your byte array, which is proven by the code snippet you provided following! Had you tried to understand what adatapost was showing you in the snippet he provided to you, your problem might already be solved!

FileStream fs = new FileStream("encrypted.txt", FileMode.Open);

            byte[] buff = null;
            BinaryReader br = new BinaryReader(fs);
            long numBytes = new FileInfo("encrypted.txt").Length;
            buff = br.ReadBytes((int)numBytes);

           mycon.Open();
           OleDbCommand cmd = new OleDbCommand("INSERT INTO song VALUES('1','" + buff + "')", mycon);
            cmd.ExecuteNonQuery();
            mycon.Close();
            fs.Close();
// above code is inserting part 

//below code is extracting part 
           byte[] temp = new byte[200000000];
           mycon.Open();

           OleDbCommand cmd = new OleDbCommand("select file from song", mycon);
           System.Data.OleDb.OleDbDataReader dr;
           dr = cmd.ExecuteReader();
           dr.Read();
           temp = (byte[])dr["file"]; //only 25 bytes i am getting
           int len = temp.Length; //25 length 

           FileStream fs = new FileStream(@"C:\Documents and Settings\SHREESHILA1\Desktop\dummy.txt", FileMode.Create);
           fs.Close();

           BinaryWriter br = new BinaryWriter(File.Open(@"C:\Documents and Settings\SHREESHILA1\Desktop\dummy.txt", FileMode.Open));


           br.Write(temp);

           //br.Write(temp);
           br.Close();  

now check the code boss, i hope now u will be able to find the problem easily

In the above, your non-use of CODE TAGS is annoying, but I think you have figured it out now since your REPOST of this problem was formatted correctly.

Also, your last statement, "now check the code boss," may have been meant to be humorous, but I felt it came across a little "smart alecky", especially since you ignored adatapost's correct example of inserting binary data while insisting you knew what you were doing, but still expecting him to help you.

I noticed you have posted in the forum 60+ times since becoming a member, so I am a little surprised, but I will assume you didn't realize the violation of reposting your problem...

commented: Well said! +6
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.