Click here to Skip to main content
15,892,161 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Respected to all,
how to add two tables in .rpt file, which has primary n foreign key relation.

And display particular value in crystalReportViewer.

This is my sql statement:
"Select Material_Master.Material_Name,Purchase.Date,Purchase.Qty,Purchase.Each_Price,Purchase.Warehouse from Purchase,Material_Master where Purchase.Material_Code=Material_Master.Material_Code AND Sr_No='"+TextBox1.Text+"'"

==>problem is that it dont display that particular values ,it display all values.

pls give me some guideline..

thanks.....
Posted
Updated 30-Jan-13 23:41pm
v3

1 solution

check this example

C#
private void button1_Click(object sender, EventArgs e)
        {
            SqlConnection cnn ;
            string connectionString = null;
            string sql = null;

            connectionString = "data source=SERVERNAME;initial catalog=DATABASENAME;user id=USERNAME;password=PASSWORD;";
            cnn = new SqlConnection(connectionString);
            cnn.Open();
            sql = "SELECT Product_id,Product_name,Product_price FROM Product";
            SqlDataAdapter dscmd = new SqlDataAdapter(sql, cnn);
            DataSet1 ds = new DataSet1();
            dscmd.Fill(ds, "Product");
            MessageBox.Show (ds.Tables[1].Rows.Count.ToString());
            cnn.Close();

            CrystalReport1 objRpt = new CrystalReport1();
            objRpt.SetDataSource(ds.Tables[1]);
            crystalReportViewer1.ReportSource = objRpt;
            crystalReportViewer1.Refresh();
        }
 
Share this answer
 

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