Datagrid-How to get data from two tables


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 6 of 6

Thread: Datagrid-How to get data from two tables

  1. #1
    Join Date
    Feb 2007
    Posts
    4

    Datagrid-How to get data from two tables

    I am using VB2003. In datagrid How do i get data from two joined tabled. For example i want get data from transactiondetail and product master. It have join with the join key productcode. I want to display all fields from transaction details including the productcode and corresponding details from product master. That is, when we will enter the productcode, immediately it has to display the product details.

    Plese help me in this.

  2. #2
    Join Date
    Dec 2004
    Posts
    163
    siraj_nm,

    Here is a great resource for VS2003 datagrid questions:

    http://www.syncfusion.com/FAQ/Window...efault.aspx#44

    Kerry Moorman

  3. #3
    Join Date
    Feb 2007
    Posts
    4
    Kmoorman

    Thank you for giving me the link. I have visted. None of it helped me.

    Thanks & Regards

    Siraj

  4. #4
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    Siraj: If I understand your question correctly, simply use a SQL query that joins the two tables, e.g.:
    Code:
    Dim cn as New SQLConnection(connectionString) 
    Dim dsProducts As New Dataset
    Dim sdaProducts As New SqlDataAdapter( _
        "SELECT ProductMaster.*, TransactionDetail.* " & _
        "FROM ProductMaster INNER JOIN TransactionDetail " & _
        "ON ProductMaster.ProductCode = TransactionDetail.ProductCode " & _
        "WHERE ProductCode = 12345", cn)
    
    sdaProducts.Fill(dsProducts, "Transactions")
    DataGrid1.SetDataBinding(dsProducts, "Transactions")
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

  5. #5
    Join Date
    Feb 2007
    Posts
    4
    Phil Weber
    Thank you for your reply. My question is not exactly you answered. Why dont i use this by relation. For example i have a common dataset named dsproduct and dstrdetail and i have established relation aswell. Why don't i join in gridcolumnstyle by its relation.

    productid.mappingname = "productid" 'this field from trdetails
    productname.mappingname = "product.productname" 'this field from product

    Please help me in this.

    Regards

    Siraj



    like this

  6. #6
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

Similar Threads

  1. emply datagrid data and insert new?
    By +Pablo in forum .NET
    Replies: 1
    Last Post: 04-27-2005, 03:16 PM
  2. Is inheritance overrated?
    By Phil Weber in forum .NET
    Replies: 67
    Last Post: 12-15-2002, 01:37 AM
  3. Displaying data from DataGrid in MS Chart
    By Tariq Anis in forum VB Classic
    Replies: 0
    Last Post: 11-18-2002, 12:34 PM
  4. Hierarchical data binding using DataGrid and ADO.NET
    By Bryan Schoening in forum .NET
    Replies: 0
    Last Post: 03-07-2002, 06:34 PM
  5. Replies: 0
    Last Post: 02-22-2001, 12:40 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center