Writing Code
 Crystal Reports Forum : Crystal Reports .NET 2003 : Writing Code
Message Icon Topic: problem from SQL expression with two tables Post Reply Post New Topic
Author Message
limcpoo
Newbie
Newbie
Avatar

Joined: 29 Jun 2009
Location: Malaysia
Online Status: Offline
Posts: 1
Quote limcpoo Replybullet Topic: problem from SQL expression with two tables
    Posted: 29 Jun 2009 at 9:30pm
hi guy..I suffer now which is..

I got 1 database with the name as test and two table which is userdetails and userearns..

in the crystal report I oni drag and drop the field that I want..then in the c# program there I code as below..

string sql = null;

            string ConnectionString = @"driver={MySQL ODBC 5.1 Driver};server=localhost;database=test;uid=root;pwd=unified;";

            OdbcConnection myConnection = new OdbcConnection(ConnectionString);
            myConnection.Open();

            //sql = "select * from testtable where testcol1 like '" + txtSearch.Text + "%'";
            //sql = "select userid,isdate,amountearn,isname,sex from (select userid,isdate,amountearn from userearns) as A left join (select userid as userid_2,isname,sex from userdetails) as B on a.userid = b.userid_2";
            //sql = "select * from userearns e left outer join userdetails d on e.userid = d.userid";
            //sql = "select a.userid,a.isdate,a.amountearn,b.isname,b.sex from userearns a, userdetails b where a.userid = b.userid";
            sql = "select userid,isdate,amountearn from userearns";
            OdbcDataAdapter myDataAdapter = new OdbcDataAdapter(sql, myConnection);

            DataSet ds = new DataSet();
            //dscmd.Fill(ds, "test");
            myDataAdapter.Fill(ds, "test");

            ReportDocument myReportDocument;
            myReportDocument = new ReportDocument();
            myReportDocument.Load("C:\\Users\\MIS User\\Documents\\Report File\\Test_report2.rpt"); // Here pass the crystall report file name
            
            myReportDocument.Database.Tables[0].SetDataSource(ds);
            //myReportDocument.SetDataSource(ds);
            //objRpt.SetDataSource(ds.Tables[1]);
            crystalReportViewer1.ReportSource = myReportDocument;
            crystalReportViewer1.Refresh();

It no error and problem and also can display it out..but the problem is it display repeadtly results..which is wrong output..may I know why this happen? it is urgent for me..ur help I will feel appreciate..thanks alotz
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.031 seconds.