Crystal Report with Image
Join now to read essay Crystal Report with Image
Create a dataset using the fields you want to display in crystal report. Define the image field as hexaBinary datatype.
Create the Crystal report using this dataset.
Now Copy this Code where you want to call the report
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Data.SqlClient;
using System.IO;
DataSet data = new DataSet();
private void PicureFromSQLDatabase()
int BUFFER_LENGTH = 152768; // chunk size
string myConnString = “SERVER=ARUN;DATABASE=Northwind;uid=sa;pwd=;”;
SqlConnection cn = new SqlConnection(myConnString);
string str_query = “SELECT * FROM Categories WHERE CategoryID > 8”;
SqlConnection cn1 = new SqlConnection(myConnString);
SqlDataReader reader;
SqlCommand cmd=new SqlCommand();
cn.Open();
cmd.CommandText=str_query;
cmd.Connection=cn;
reader=cmd.ExecuteReader();
data.Tables.Add();
int sNo = 1;
float targetWidth = 0;
float targetHeight = 0;
float imageWidth = 0;
float imageHeight =0;
float widthRatio = 0;
float heightRatio =0;
float optimalRatio = 0;
int xImgBoundary=0;
int yImgBoundary=0;
int widthImgBoundary=0;
int heightImgBoundary=0;
byte[] bitmapData = new byte[2000];
while (reader.Read())
SqlCommand cmdGetPointer = new SqlCommand(“SELECT @Pointer=TEXTPTR(Picture), @Length=DataLength(Picture) FROM ” +
SqlParameter PointerOutParam = cmdGetPointer.Parameters.Add(“@Pointer”, SqlDbType.VarBinary, 100);
PointerOutParam.Direction = ParameterDirection.Output;
SqlParameter LengthOutParam = cmdGetPointer.Parameters.Add(“@Length”, SqlDbType.Int);
LengthOutParam.Direction = ParameterDirection.Output;
cn1.Open();
cmdGetPointer.ExecuteNonQuery();
if (PointerOutParam.Value == DBNull.Value)
cn1.Close();
SqlCommand cmdReadBinary = new SqlCommand(“READTEXT Categories.Picture @Pointer @Offset @Size HOLDLOCK”, cn1);
SqlParameter PointerParam = cmdReadBinary.Parameters.Add(“@Pointer”, SqlDbType.Binary, 16);
SqlParameter OffsetParam = cmdReadBinary.Parameters.Add(“@Offset”, SqlDbType.Int);
SqlParameter SizeParam = cmdReadBinary.Parameters.Add(“@Size”, SqlDbType.Int);
SqlDataReader dr;
System.IO.FileStream fs = new System.IO.FileStream(“c:abc.jpg”, System.IO.FileMode.Create,
Essay About Sqlcommand Cmd And New Dataset
Essay, Pages 1 (267 words)
Latest Update: June 22, 2021
//= get_the_date(); ?>
Views: 53
//= gt_get_post_view(); ?>
Sqlcommand Cmd And New Dataset. (June 22, 2021). Retrieved from https://www.freeessays.education/sqlcommand-cmd-and-new-dataset-essay/