Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Load a picture in runtime

Posted on 2004-08-15
9
Medium Priority
?
2,119 Views
Last Modified: 2008-02-01
Hello everybody!!
First, is it possible to load a picture on runtime using de RDC version from vb.net? what a have to do is to load diferent pictures from their paths information. I also have to change some labels' caption when the report is loading. Is it possible to do it using RDC or do I need to change to other different version of Crystal Repots?

Could anyone tell me how to develop this?
thanx.
0
Comment
Question by:Robertonio
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 19

Expert Comment

by:GJParker
ID: 11807884
Here is a sapmple from BO using the Section_Formoat Event on how to load pictures using the RDC at runtime

http://support.businessobjects.com/communityCS/FilesAndUpdates/cr9_vb_rdc_loadpic.exe.asp

This should help you with the text formattiing you require

http://support.businessobjects.com/communityCS/FilesAndUpdates/employeeprofiledemo.zip.asp

Gary
0
 
LVL 10

Expert Comment

by:ebolek
ID: 11810295
This is how I do it. Hopefully it helps. If you need explanation, let me know
Regards
Emre

private void DynamicImages()
            {
                  DataSet MyDataSet = new DataSet();
                  DataTable MyDataTable;
                  DataRow MyDataRow;
                  MyDataTable = new DataTable();
                  DataColumn MyDataColumn = new DataColumn();
                  //Create the first column
                  MyDataColumn = new DataColumn("PicNumber", Type.GetType("System.Int32"));
                  MyDataTable.Columns.Add(MyDataColumn);  
                  //Field that points to the image file
                  MyDataColumn = new DataColumn("ImagePath", Type.GetType("System.String"));
                  MyDataTable.Columns.Add(MyDataColumn);
                  //populate the table with dummy data
                  MyDataRow = MyDataTable.NewRow();
                  MyDataRow["PicNumber"] = 1;
                  MyDataRow["ImagePath"] = "C:\\Image1.jpg";
                  MyDataTable.Rows.Add(MyDataRow);
                  MyDataSet.Tables.Add(MyDataTable);
                  //Add the image column to the table
                  AddImageColumn(MyDataTable, "Image");
                  //only do this when you first design the report
                  MyDataSet.WriteXmlSchema(@"c:\ImageTable.xsd");
                  //Load the images into the dataset
                  LoadAllImages(MyDataTable, "ImagePath", "Image");
                  

            }
            public void AddImageColumn(DataTable MyDataTable, string FieldName)
            {
                  //create the column to hold the binary image
                  DataColumn MyDataColumn = new DataColumn(FieldName,Type.GetType("System.Byte[]"));
                  MyDataTable.Columns.Add(MyDataColumn);
            }
            public void LoadAllImages(DataTable MyDataTable,string FilePathField, string ImageField)
            {
                  foreach(DataRow MyDataRow in MyDataTable.Rows )
                  {
                        LoadImage(MyDataRow, ImageField, MyDataRow[FilePathField].ToString());
                  }
            }
            public void LoadImage(DataRow MyDataRow, string ImageField, string FilePath)
            {
                  FilePath = "c:\\Image1.jpg";
                  System.IO.FileStream fs = new System.IO.FileStream(FilePath, System.IO.FileMode.Open,System.IO.FileAccess.Read);
                  Byte[] Image = new Byte[fs.Length];
                  fs.Read(Image, 0, (int)fs.Length);
                  fs.Close();
                  MyDataRow[ImageField] = Image;  
            }            
            public void CreateXMLSchemaFile(string XMLFileName, DataSet XMLDataSet)
            {
                  XMLDataSet.WriteXmlSchema("ImageDataSchema") ;
            }
            public DataSet FillDataSet(DataSet MyDataSet)
            {
                  SqlConnection MyConnectionString = new SqlConnection("server=OMEGA_DEV;database=omega_test;UID=OmegaWeb;PWD=JascPSP6;");
                  string SQL;
                  SQL = "uspReportData";            
                 
                  //Create a DataAdapter, and then provide the name of the stored procedure.
                  SqlDataAdapter MyDataAdapter = new SqlDataAdapter(SQL, MyConnectionString);

                  //Set the command type as StoredProcedure.
                  MyDataAdapter.SelectCommand.CommandType = CommandType.StoredProcedure;

                  //Create and add a parameter to Parameters collection for the stored procedure.
                  MyDataAdapter.SelectCommand.Parameters.Add(new SqlParameter("@CaseID", SqlDbType.VarChar, 25));
                  MyDataAdapter.SelectCommand.Parameters.Add(new SqlParameter("@line_number", SqlDbType.Int));
                  MyDataAdapter.SelectCommand.Parameters.Add(new SqlParameter("@company_id", SqlDbType.VarChar, 4));
                  //Assign the search value to the parameter.
                  MyDataAdapter.SelectCommand.Parameters["@CaseID"].Value = _parametervalues[0];
                  MyDataAdapter.SelectCommand.Parameters["@line_number"].Value = _parametervalues[1];
                  MyDataAdapter.SelectCommand.Parameters["@company_id"].Value = _parametervalues[2];
                  MyDataAdapter.Fill(MyDataSet.Tables["uspReportData"]);
                  return MyDataSet;
            }
            private bool HasParameter(CrystalDecisions.CrystalReports.Engine.ReportDocument MyReport)
            {
                  if (MyReport.DataDefinition.ParameterFields.Count == 0)  
                  {
                        _HasParameters = false;
                        return _HasParameters;
                  }
                  else
                  {
                        _HasParameters = true;
                        return _HasParameters;
                  }
            }
0
 
LVL 1

Author Comment

by:Robertonio
ID: 11823017
It seems to be useful, but, every crystal reports have objects witch I cannot access (with VB.net) in order to modify them and insert the text and pictures I need. Do you know how to do it using VB.NET, there are a loads of examples with VB6.
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 10

Accepted Solution

by:
ebolek earned 750 total points
ID: 11823060
My code that I posted here allows you to change the pictures runtime. i dont understand what are you asking. can you explain better
0
 
LVL 1

Author Comment

by:Robertonio
ID: 11824714
ok. thanx  I was making a mistake when passing this code to .net, thanx ebolex
0
 
LVL 1

Author Comment

by:Robertonio
ID: 11894602

Ebolek the code you sent me works correctly
but? how can I insert a column (wich contains the path information) that i have already loaded into my data set instead using those rows and columns that you use in your example
0
 
LVL 10

Expert Comment

by:ebolek
ID: 11894896
when you create your dataset, you add extra columns like report path and file name etc. Then you ssave your report with that dataset as dtaasource. Then you use my code to set the values of thiose cloumns and populate the images
0
 

Expert Comment

by:BuuTran159
ID: 12042373
Hi,
Cool thread, another thing that it is great if you can help...

Can we resize of change some properties to make make image is the same aspect with it origin size. ie. currently the image is strected full control size. I can do it in VB6& CR by resize the controls in run-time, but for ASP.NET I don't know how to do now.

Thanks in advanced.

Buu.
0
 
LVL 10

Expert Comment

by:ebolek
ID: 12043825
i think you can there is image to respect ratio and that should solve your problem. I dont know exactly the code to write because i never tries it but if you can it should be under

reportdefinitions.pictureobjects properties

Regards
Emre
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question