5
Answers

How to store image in Sql Server Database using C# ?

Dear All 

I am try to convert image in byte then insert it into Database using C#.Below is my code .........



public byte[] getImageData(string strFleNm)
        {
            byte[] ImgData = null;

            FileInfo fileinfo = new FileInfo(strFleNm);
            long imagefilelenght = strFleNm.Length;
            FileStream Fs = new FileStream(strFleNm, FileMode.Open, FileAccess.Read);
            BinaryReader Br = new BinaryReader(Fs);
            ImgData = Br.ReadBytes((int)imagefilelenght);
            return ImgData;
       }

but its give error,Error is like Could not find image .....................
Answers (5)