Click here to Skip to main content
11,411,494 members (64,969 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET
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 31-Jan-13 0:15am
Edited 31-Jan-13 0:41am
v3

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

check this example

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();
        }
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 223
1 Sascha Lefévre 155
2 Sergey Alexandrovich Kryukov 149
3 ProgramFOX 90
4 Dave Kreskowiak 90
0 Sergey Alexandrovich Kryukov 8,920
1 OriginalGriff 7,128
2 Maciej Los 3,440
3 Abhinav S 3,248
4 Peter Leow 3,059


Advertise | Privacy | Mobile
Web03 | 2.8.150414.5 | Last Updated 31 Jan 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100