Solved

Failed to load database information error - crystal report in c# with SQL Server

Posted on 2016-10-03
15
82 Views
Last Modified: 2016-10-10
My code works fine and the report opens  When excute code from visual studio but when  I try to open the same report after installation or on  another machine, I get this error.
Failed to load database information. Error in File temp_92bf354f-8e8f-4bb8-adc9-3699bf6fef86 996_4916_{76EC69A0-4A21-4077-89D4-12F6242DFCEF}.rpt: Failed to load database information.

System.Runtime.InteropServices.COMException: Failed to load database information. Error in File temp_92bf354f-8e8f-4bb8-adc9-3699bf6fef86 996_4916_{76EC69A0-4A21-4077-89D4-12F6242DFCEF}.rpt: Failed to load database information.

I'm using Visual Studio 2013 with SQL Server 2012 and Crystal Report v3_0_16. My PC runs Windows 10 64 bit. I've opened it on a 64-bit machine and 32-bit machine, but both get the same error.
note : I have installed crystal report runtime 64 bit and 32 bit but still same issue .
 How do I solve this?
0
Comment
Question by:naseem iebow
[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
  • 8
  • 4
  • 2
  • +1
15 Comments
 
LVL 18

Expert Comment

by:vasto
ID: 41827440
What kind of connection do you use ? If it is ODBC you need to create a DSN on the other machine. If it is not ODBC then you probably miss a driver on the other machine. What is your database ?
0
 

Author Comment

by:naseem iebow
ID: 41827445
the database is on same machine and i use the following code :
 print_store_counts_dataset ds = new print_store_counts_dataset();
cmd.CommandText = "select rec_items.id,items.iname,items_count.count,item_code from items inner join items_count on items.code=items_count.item_code  inner join rec_items on items_count.rec_num=rec_items.id where isclose=0 ";
            con.Open();
            SqlCommand cmd_details = new SqlCommand("", con);
            SqlDataReader reader = cmd.ExecuteReader();
       int i = 0;
   
                while (reader.Read())
                {
                    cmd_details.CommandText = "select sum(count) from bills_details where    reciver_number=@rn and item_code=@ic ";
                    cmd_details.Parameters.Clear();
                    cmd_details.Parameters.AddWithValue("@rn", reader["id"].ToString());
                    cmd_details.Parameters.AddWithValue("@ic", reader["item_code"].ToString());
                    int payed = 0;
                    object res = cmd_details.ExecuteScalar();

                    if (res.GetType() != typeof(DBNull))
                    {

                        payed = Convert.ToInt32(cmd_details.ExecuteScalar());
                    }

                    /*if (cmd_details.ExecuteScalar() !=null)
                        payed = Convert.ToInt32(cmd_details.ExecuteScalar());*/
                    /*
                    ds.Tables["store_counts"].Rows.Add();
                   
                    ds.Tables["store_counts"].Rows[i].SetField("rec_num", reader["id"].ToString());
                    ds.Tables["store_counts"].Rows[i].SetField("item_name", reader["iname"].ToString());
                    ds.Tables["store_counts"].Rows[i].SetField("item_code", reader["item_code"].ToString());
                    ds.Tables["store_counts"].Rows[i].SetField("count_sup", reader["count"].ToString());
                    ds.Tables["store_counts"].Rows[i].SetField("count_pay", payed);
                    ds.Tables["store_counts"].Rows[i].SetField("count_remain", Convert.ToInt32(reader["count"]) - payed);
                    
                    i++;*/

                    
                }

print_store_counts_reports cr = new print_store_counts_reports();
cr.SetDataSource(ds);
            
            cr.Refresh();
            crystalReportViewer1.ReportSource = cr;
           
            crystalReportViewer1.Refresh();

Open in new window

0
 
LVL 49

Expert Comment

by:PortletPaul
ID: 41827592
Im guessing here but this catches my eye:

con.Open();

What connection is it opening? Have you defined what,or importantly, where, the data source is?
0
Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

 

Author Comment

by:naseem iebow
ID: 41827623
As i mentioned this code work fine when excute in visual but when deploy ans install it on machine didnot work.
Before this lines i define connection and connection string and the connection open correctly
0
 
LVL 49

Expert Comment

by:PortletPaul
ID: 41827833
Failed to load database information is stated in the error message so the problem is in those comnection details I  think.
0
 

Author Comment

by:naseem iebow
ID: 41827913
yes maybe the problem in connection but how i can solve it ??
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 41828043
have you tried to encapsulate your code in a try ... catch structure and look at the exception? you might find other indices to help you find the issue.

I would also surround disposable objects (dataset, connection, command, ...) with using {} to ensure you are closing your objects: https://msdn.microsoft.com/en-us/library/yh598w02.aspx?f=255&MSPPError=-2147217396
0
 
LVL 18

Expert Comment

by:vasto
ID: 41828085
I don't think the error is coming from the code above. Do you have a subreport ? If you do, the error is coming from the subreports because you are setting the main report datasource , but the subreport is still trying to connect. If you don't have a subreport then the SetDataSource is not working and the report is still trying to connect using the internal database connection
0
 

Author Comment

by:naseem iebow
ID: 41828493
i use try .. catch but there is no errors , and as i noticed the error come when using the application interrupted when execute this command cr.SetDataSource(ds);
i wasn't use sub reports and if setDataSource is not working so what the solution ?
0
 
LVL 18

Expert Comment

by:vasto
ID: 41828538
You are declaring the dataset ds , but it was never filled with data. The code , which supposed to load data is commented. print_store_counts_dataset is a strongly typed dataset and there might be some connection associated with it in design time. Check what this connection is doing
0
 

Author Comment

by:naseem iebow
ID: 41828596
Dear Vasto ,
the code that filled data set is commented temporary because i make some test but this error appears also when put it not commented .
about dataset "print_store_counts_dataset " there is no connection in design page because as you see from above code in this dataset I create data table and filled this data table from this code .
thanks
0
 
LVL 18

Expert Comment

by:vasto
ID: 41828598
then , try to pass the table and not the whole dataset

cr.SetDataSource( ds.Tables["store_counts"]);
0
 

Author Comment

by:naseem iebow
ID: 41828626
Unfortunately , same issue :(
0
 

Accepted Solution

by:
naseem iebow earned 0 total points
ID: 41829731
the problem solved by copy the configuration file in same installation folder .
thanks all for help
0
 

Author Closing Comment

by:naseem iebow
ID: 41836591
because my solution repair the issue by coping configuration file to same installation folder
0

Featured Post

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

615 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