المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Showing Picture in Crystal Reports from Table



C# Programming
08-21-2011, 04:30 AM
hi all

I have uploaded a picture into table but i am stuck, that how may I show the picture in Crystal Reports from table.

I used following codes to upload the picture it works fine

// load the file that we want to upload into memory fileStream = new System.IO.FileStream(strFile, System.IO.FileMode.Open, System.IO.FileAccess.Read); reader = new System.IO.BinaryReader(fileStream); data = reader.ReadBytes((int)fileStream.Length); // open the connection to the database //conn = new System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + AccessFile.Text); //conn.Open(); // determine if the file already exists. If the file does not already // exist, add the file to the table. cmd = new OleDbCommand(); cmd.Connection = Module.objConnection; string strQuery = "SELECT * FROM PICTURES WHERE " + "STCODE="+ textBox1.Text +" AND " + "STSEQ="+ dataGridView1["STSEQ",dataGridView1.CurrentCell.RowIndex].Value.ToString() +" "; cmd.CommandText = strQuery; dr = cmd.ExecuteReader(); if (dr.HasRows == false) { dr.Close(); cmd.CommandText = "INSERT INTO PICTURES (STCODE,STRNO,STSEQ,FILENAME,FILESIZE,FILETYPE) " + "VALUES(" + textBox1.Text + ", " + "" + dataGridView1["STRNO", dataGridView1.CurrentCell.RowIndex].Value.ToString() + ", " + "" + dataGridView1["STSEQ", dataGridView1.CurrentCell.RowIndex].Value.ToString() + ", " + "'" + fileName + "'," + data.Length + ",'" + type + "') "; //cmd.CommandText = "INSERT INTO PICTURES (STCODE,STRNO,STSEQ,FILENAME,FILETYPE) " + // "VALUES(" + textBox1.Text + ", " + // "" + dataGridView1["STRNO", dataGridView1.CurrentCell.RowIndex].Value.ToString() + ", " + // "" + dataGridView1["STSEQ", dataGridView1.CurrentCell.RowIndex].Value.ToString() + ",'" + textBox1.Text.Trim() + "_" + textBox2.Text.Trim() + "." + type + "') "; // //"'" + fileName + "'," + data.Length + ",'" + type + "') "; cmd.ExecuteNonQuery();
(Riaz)