Click here to Skip to main content
13,043,491 members (52,340 online)
Rate this:
Please Sign up or sign in to vote.
i have web application in which i need to create crystal that i have dataset named "dsHeader" which is assigned to crystal report as datasource.In this report i need to show image.
I get data from database and get stored in one of table nad then merge this datable with `dsheader` below is the code i tried

SalesHeader dsHeader = new SalesHeader();
            DataTable dt=new DataTable();
            dt.Columns.Add("ShipAddress", typeof(System.String));
            dt.Columns.Add("Companyname", typeof(System.String));
            dt.Columns.Add("Companyaddress", typeof(System.String));
            dt.Columns.Add("CompEmail", typeof(System.String));
            dt.Columns.Add("CompTelephone", typeof(System.String));
            dt.Columns.Add("logoname", typeof(System.Byte[]));
            Dataset imageDataSet=Getdata();//retrieve data from database
              for (int rowNumber = 0; rowNumber < imageDataSet.Tables[0].Rows.Count; rowNumber++)
     imageDataSet.Tables[0].Rows[rowNumber]["logoname"] = GetByteArray("abc.jpg");
        dt.Rows.Add(imageDataSet.Tables[0].Rows[rowNumber][0].ToString(), imageDataSet.Tables[0].Rows[rowNumber][1].ToString(), imageDataSet.Tables[0].Rows[rowNumber][2].ToString(), imageDataSet.Tables[0].Rows[rowNumber][3].ToString(), imageDataSet.Tables[0].Rows[rowNumber][4].ToString(), imageDataSet.Tables[0].Rows[rowNumber][5] as System.Byte[]);
    dsHeader.Tables[0].Merge(dt,true, MissingSchemaAction.Ignore);

On this line
`dsHeader.Tables[0].Merge(dt,true, MissingSchemaAction.Ignore);`
i am getting this error:
 Type of value has a mismatch with column typeCouldn't store System.Byte[]> in logoname Column.  Expected type is Byte[].
this function returns image with byte aaray

private byte[] GetByteArray(String strFileName)
                System.IO.FileStream fs = new System.IO.FileStream(strFileName, System.IO.FileMode.Open);
                // initialise the binary reader from file streamobject
                System.IO.BinaryReader br = new System.IO.BinaryReader(fs);
                // define the byte array of filelength
                byte[] imgbyte = new byte[fs.Length + 1];
                // read the bytes from the binary reader
                imgbyte = br.ReadBytes(Convert.ToInt32((fs.Length)));
                // add the image in bytearray
                // close the binary reader
                // close the file stream
                return imgbyte;

The "logoname" field in dsHeader dataset is of System.Byte[] type.
please Help me for this.
Posted 31-Oct-12 22:00pm

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 1 Nov 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100