944,117 Members | Top Members by Rank

Ad:
  • C# Discussion Thread
  • Unsolved
  • Views: 2356
  • C# RSS
Oct 26th, 2009
0

Extracting report form oracle database

Expand Post »
hi every body

i have a trouble with viewing the report from using the following environments


C# - Crystalreport - Oracle database

i regularly use the basic way to call a view form the database and extract the data form it like that

C# Syntax (Toggle Plain Text)
  1. cmd.commandtext= "Create view as select * from table1 where icode = '10'";
  2.  
  3. cmd.excutenonquery();


and then create a report depending on this view

and regally connect your report viewer with this view

and its working with viewing the report via crystalreport
it's absolutely good for access database ans SQL server
but i's so bad when dealing with oracle database

when i use this past method i found a messagebox showing tell me that it need the user password in oracle database

so i have a trouble to make instance from my report in c#

i follow the following method but it also doesn't work !!

C# Syntax (Toggle Plain Text)
  1. OleDbConnection cn = new OleDbConnection();
  2. OleDbCommand cmdtest = new OleDbCommand();
  3. OleDbDataReader drrr;
  4. OleDbDataAdapter ad = new OleDbDataAdapter();
  5. DataTable dt = new DataTable();
  6. if (cn.State == ConnectionState.Closed)
  7. {
  8. cn.ConnectionString = "provider=oraoledb.oracle.1;password=123;user id = system;";
  9. cn.Open();
  10. }
  11. DataSet ds = new DataSet();
  12. cmdtest.Connection = cn;
  13. cmdtest.CommandType = CommandType.Text;
  14. cmdtest.CommandText = "select * from doc ";
  15. drrr = cmdtest.ExecuteReader();
  16. drrr.Close();
  17. CrystalDecisions.CrystalReports.Engine.ReportClass ss = new CrystalDecisions.CrystalReports.Engine.ReportClass();
  18. ad.SelectCommand = cmdtest;
  19. ad.Fill(ds, "doc");
  20. ss.ResourceName = "docreport.rpt";
  21. ss.SetDataSource(ds.Tables["doc"]);
  22. crystalReportViewer1.ReportSource = ss;



so if you have any idea what i'm wrong about please tell me

thanks a lot
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
samehsenosi is offline Offline
10 posts
since Sep 2009
Oct 26th, 2009
0
Re: Extracting report form oracle database
It sounds like you need to set the report's connection info for each of the tables. Try passing in the ReportDocument to this after you have set the table parameters, but before attempting to run/view the report:

C# Syntax (Toggle Plain Text)
  1. public static void ReportSourceSetup(ReportDocument crDoc, ConnectionInfo crConnectionInfo)
  2. {
  3. // Each table in report needs to have logoninfo setup:
  4. Tables crTables = crDoc.Database.Tables;
  5. foreach (CrystalDecisions.CrystalReports.Engine.Table crTable in crTables)
  6. {
  7. TableLogOnInfo crTableLogonInfo = crTable.LogOnInfo;
  8. crTableLogonInfo.ConnectionInfo = crConnectionInfo;
  9. crTable.ApplyLogOnInfo(crTableLogonInfo);
  10. }
  11. }
Reputation Points: 341
Solved Threads: 233
Posting Shark
DdoubleD is offline Offline
984 posts
since Jul 2009
Oct 27th, 2009
0
Re: Extracting report form oracle database
Hi samehsenosi,

Datasource is not specified in the connection string.

Set the data source and try it again.
Reputation Points: 165
Solved Threads: 113
Posting Pro
Ramesh S is offline Offline
580 posts
since Jun 2009
Oct 27th, 2009
0
Re: Extracting report form oracle database
hi DdoubleD

most thanks about your share
but if you tell me the complete right way for this problem !!!
cause i try to follow your steps but there's something missing in my steps...

so please tell me the whole way to it

thanks a lot





Click to Expand / Collapse  Quote originally posted by DdoubleD ...
It sounds like you need to set the report's connection info for each of the tables. Try passing in the ReportDocument to this after you have set the table parameters, but before attempting to run/view the report:

C# Syntax (Toggle Plain Text)
  1. public static void ReportSourceSetup(ReportDocument crDoc, ConnectionInfo crConnectionInfo)
  2. {
  3. // Each table in report needs to have logoninfo setup:
  4. Tables crTables = crDoc.Database.Tables;
  5. foreach (CrystalDecisions.CrystalReports.Engine.Table crTable in crTables)
  6. {
  7. TableLogOnInfo crTableLogonInfo = crTable.LogOnInfo;
  8. crTableLogonInfo.ConnectionInfo = crConnectionInfo;
  9. crTable.ApplyLogOnInfo(crTableLogonInfo);
  10. }
  11. }

samehsenosi
Reputation Points: 10
Solved Threads: 0
Newbie Poster
samehsenosi is offline Offline
10 posts
since Sep 2009
Oct 27th, 2009
0
Re: Extracting report form oracle database
Is this what you are looking for?:

C# Syntax (Toggle Plain Text)
  1. private void RunMyReport(ReportDocument crDoc)
  2. {
  3. ConnectionInfo crConnectionInfo = new ConnectionInfo();
  4. crConnectionInfo.ServerName = "YOUR SERVER NAME";
  5. crConnectionInfo.DatabaseName = "YOUR DATABASE NAME";
  6. crConnectionInfo.UserID = "YOUR DATABASE USERNAME";
  7. crConnectionInfo.Password = "YOUR DATABASE PASSWORD";
  8.  
  9. // setup before passing to the viewer...
  10. ReportSourceSetup(crDoc, crConnectionInfo);
  11.  
  12. crystalReportViewer1.ReportSource = crDoc;
  13. crystalReportViewer1.Refresh();
  14. }
  15. public static void ReportSourceSetup(ReportDocument crDoc, ConnectionInfo crConnectionInfo)
  16. {
  17. // Each table in report needs to have logoninfo setup:
  18. Tables crTables = crDoc.Database.Tables;
  19. foreach (CrystalDecisions.CrystalReports.Engine.Table crTable in crTables)
  20. {
  21. TableLogOnInfo crTableLogonInfo = crTable.LogOnInfo;
  22. crTableLogonInfo.ConnectionInfo = crConnectionInfo;
  23. crTable.ApplyLogOnInfo(crTableLogonInfo);
  24. }
  25. }
  26.  
  27. // calling...
  28. RunMyReport(ss);
Reputation Points: 341
Solved Threads: 233
Posting Shark
DdoubleD is offline Offline
984 posts
since Jul 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C# Forum Timeline: Calling a methond
Next Thread in C# Forum Timeline: how to get the row id of the clicked row in a HTML table using c#





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC