Click here to Skip to main content
15,905,875 members
Please Sign up or sign in to vote.
1.33/5 (2 votes)
See more:
Hello everybody again!

I have a little problem with my report, the problem is that I have a
data in a datagridview. and next I import this information in to a
Crystal report but the time data do not appear in the repective column.

Let me show you a image to illustrate this case:




the code that i use is:

1) asign the datagridview source to a global dataset variable:

this.dataGridView2.DataSource = detaDs.Tables["dt"];
dataReport = new DataSet();
dataReport = detaDs;

2) Click button "Imprime" next I open a windows form with the report object and i make all operations to import the data into a report.

new TarjeteroSharp.Form3(this.dataReport).Show();

public Form3(DataSet myData)
        {
            InitializeComponent();
            myDataGlobal = myData;

            object result = TarjeteroSharp.WaitWindow.Show(this.workerMethod2);
            try { System.Console.Out.WriteLine(result.ToString()); }
            catch { System.Console.Out.WriteLine("No se puede imprimir result2"); }

            this.crystalReportViewer1.ReportSource = rpt1;
            this.crystalReportViewer1.Refresh();
            myData.Dispose();
            myDataGlobal.Dispose();

        }

        private void workerMethod2(object sender, TarjeteroSharp.WaitWindowEventArgs e)
        {
            this.showInfo2(myDataGlobal);
        }

        private void showInfo2(DataSet myData)
        {

            /*PREPARANDO LA DATA ANTES DE ASIGNARLA:*/
            myData.Tables[0].TableName = "tarjeta1";
            rpt1.SetDataSource(myData.Tables["tarjeta1"]);
        }


You can look I have a "tarjeta1" is a data_set the columns in this data
set is the same column in the datagridview

Please tell me if a rpt object (crystal object) have a properties and features
that formatting the cells to allow time data. because in my case this data dont appear in the report.

Thanks in advance.
Posted
Updated 18-Jan-11 9:46am
v2

Try this

Time Conversions in Crystal Reports[^]

[EDIT]
If it's a Datetime field you can format that by below way
Formatting Dates in Crystal reports[^]
[/EDIT]
 
Share this answer
 
v2
Comments
leocode7 19-Jan-11 10:36am    
hello, the problem is the formatting.
Do you tell me how i can modify the type to a CTime ?????
Becasuse i need to show the Horus:Minutes:Seconds (HH:MM:SS)
Thanks.
thatraja 19-Jan-11 11:01am    
Check my updated answer.
leocode7 19-Jan-11 12:26pm    
Hello, I'm trying to add a DataTime Field in my crystal report,
but i can't asign the value of my Object.
How I use the record selection to put the data in my DataTime field?????
I found the solution!!!

The problem was I don't made a good mapping from the dataset to ADO object
specifically in the name of column.

for example:
sqlqwery="select vuelta,linea.linea,salida,vsalida as ver,R1,M1,AT1,AD1,R2,M2,AT2,AD2,R3,M3,AT3,AD3,R4,M4,AT4,AD4,R5,M5,AT5,AD5 from deta_tarjeta,linea where deta_tarjeta.cod_tar='"+tarjeta.cod+"' and deta_tarjeta.cod_lin=linea.cod order by vuelta asc"; 



conexion con = new conexion();
            detaDs = con.consulta(sqlqwery);

            this.dataGridView2.DataSource = detaDs.Tables["dt"];
            dataReport = new DataSet();
            dataReport = detaDs;


myData=dataReport;
tarjetero1 rpt1 = new tarjetero1();
myData.Tables[0].TableName = "tarjeta1";
rpt1.SetDataSource(myData.Tables["tarjeta1"]);
this.crystalReportViewer1.ReportSource = rpt1;
this.crystalReportViewer1.Refresh();
myData.Dispose();




the names in the sql query must be same than the xsd object showing in the picture, then there are a good mapping and the data is appear in the report.

thanks for your atention.

Regards,

Leo
 
Share this answer
 
v3
I just suspect it might be the column size of the date field in report. Can you increase the width and see if it works?
 
Share this answer
 
Comments
leocode7 19-Jan-11 10:36am    
hello, the problem is the formatting.
Do you tell me how i can modify the type to a CTime ?????
Becasuse i need to show the Horus:Minutes:Seconds (HH:MM:SS)
Thanks.

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900