Extracting report form oracle database

Please support our C# advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Sep 2009
Posts: 7
Reputation: samehsenosi is an unknown quantity at this point 
Solved Threads: 0
samehsenosi samehsenosi is offline Offline
Newbie Poster

Extracting report form oracle database

 
0
  #1
Oct 26th, 2009
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

  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 !!

  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
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 972
Reputation: DdoubleD is a jewel in the rough DdoubleD is a jewel in the rough DdoubleD is a jewel in the rough DdoubleD is a jewel in the rough 
Solved Threads: 213
DdoubleD DdoubleD is offline Offline
Posting Shark
 
0
  #2
Oct 26th, 2009
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:

  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. }
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 452
Reputation: Ramesh S will become famous soon enough Ramesh S will become famous soon enough 
Solved Threads: 82
Ramesh S Ramesh S is offline Offline
Posting Pro in Training
 
0
  #3
Oct 27th, 2009
Hi samehsenosi,

Datasource is not specified in the connection string.

Set the data source and try it again.
Reply With Quote Quick reply to this message  
Join Date: Sep 2009
Posts: 7
Reputation: samehsenosi is an unknown quantity at this point 
Solved Threads: 0
samehsenosi samehsenosi is offline Offline
Newbie Poster
 
0
  #4
Oct 27th, 2009
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





Originally Posted by DdoubleD View Post
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:

  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
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 972
Reputation: DdoubleD is a jewel in the rough DdoubleD is a jewel in the rough DdoubleD is a jewel in the rough DdoubleD is a jewel in the rough 
Solved Threads: 213
DdoubleD DdoubleD is offline Offline
Posting Shark
 
0
  #5
Oct 27th, 2009
Is this what you are looking for?:

  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);
Reply With Quote Quick reply to this message  
Reply

Tags
c#, oracle

Message:




Views: 630 | Replies: 4
Thread Tools Search this Thread



Tag cloud for c#, oracle
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC