Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB.NET
|
VB.NET General VB.NET discussions for issues that don't fall into other VB.NET forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB.NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 31st, 2006, 01:25 PM
ct ct is offline
Authorized User
 
Join Date: Aug 2005
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
Default Select data from two different table

how i want to select the data from two different table from ms access and display it in VB.Net...for example..
select id from table A and title from table B...and display it in one form in VB.Net. anyone can help?

 
Old October 31st, 2006, 07:15 PM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

Your SQL should be:
Code:
SELECT A.ID, B.TITLE
FROM   [table A] AS A, 
        [table B] AS B
WHERE  A.[Some Field] = B.[Some Field]
You might need to drop the word “AS” from the FROM clause; different DBs handle that better than others.
 
Old November 1st, 2006, 04:46 AM
ct ct is offline
Authorized User
 
Join Date: Aug 2005
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
Default

but in vb.net the language is different. i don't know how to code and retrieve the data from ms access and code it in vb.net. can u show me simple example?


 
Old November 1st, 2006, 12:48 PM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

I haven't done musch with this, but I have done enough to feel confident of this answer:

In the toolbar there are several Data-oriented controls. Data adapters, data grids, etc.

In help, there are tutorials on how to connect to data.

Follow one of these tutorials, then adapt the results to your specific need (using SQL similar to what I posted before.

When you add the controls (etc.) to your project from the toolbar, the code to create them is added to your project in a collapsed region. Expand that region to see what VB.NET did to implement your dragging and dropping.
 
Old November 1st, 2006, 09:51 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,093
Thanks: 1
Thanked 12 Times in 11 Posts
Default

Here's the basic of working with a DataSet populated from an Access db, though as always there are a number of ways to do this sort of stuff:

Code:
Imports System.Data.OleDb

Module Module1

   Sub Main()
      Dim strConn As String = "Provider=Microsoft.Jet.OleDb.4.0;Data Source=" & _
           "C:\Northwind.mdb;"

      Dim cn As New OleDbConnection(strConn)
      Dim da As OleDbDataAdapter = New OleDbDataAdapter
      Dim ds As DataSet
      Dim row As DataRow

      da.TableMappings.Add("Table", "Customers")
      cn.Open()
      Dim cmd As OleDbCommand = New OleDbCommand("SELECT * FROM Customers", cn)
      cmd.CommandType = CommandType.Text
      da.SelectCommand = cmd
      ds = New DataSet("Customers")
      da.Fill(ds)

      ' Dump dataset contents to Console window
      Dim oRow As DataRow
      Dim strRecord As String

      For Each oRow In ds.Tables("Customers").Rows
         strRecord = "Customer Id: " & oRow("CustomerId").ToString()
         strRecord = strRecord & "  Company Name: "
         strRecord = strRecord & oRow("CompanyName").ToString()
         Console.WriteLine(strRecord)
      Next
      cn.Close()
   End Sub

End Module
Just point the connection string toa copy of the Northwind database.

HTH,

Bob

 
Old August 31st, 2007, 02:14 AM
Registered User
 
Join Date: Aug 2007
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello,
Can u help me on, How to create DataView by executing Join Queries on DataSet (Not on Database)
Tej.

 
Old August 31st, 2007, 02:17 AM
Registered User
 
Join Date: Aug 2007
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello,
Can u help me on, How to create DataSet by executing Join queries on DataSet ( Not on DataBase )
Tej.
 
Old August 31st, 2007, 02:20 AM
Registered User
 
Join Date: Aug 2007
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Sorry,
I want to correct my last Question.
Can u help me on, How to create DataView by executing Join queries on DataSet ( Not on DataBase )
Tej.

 
Old August 31st, 2007, 08:23 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

To my knowledge, you can't do this directly in a dataset. You can establish row filters on a dataview in order to restrict the data table results. Also, you can establish relationships between data tables in a data set and use the data table functionality to get child rows based on relationships.

-Peter





Similar Threads
Thread Thread Starter Forum Replies Last Post
How I insert button into table for select row. oatza ASP.NET 2.0 Basics 5 May 10th, 2006 12:09 AM
Dataset.Table.Select Method EricJ Pro VB.NET 2002/2003 2 September 25th, 2005 09:36 AM
How to select 5th Max in a Table ramk_1978 SQL Language 2 December 30th, 2004 01:41 AM
select into non-temp table? (existing) nlicata SQL Server 2000 3 November 7th, 2003 03:11 PM
Select records NOT in table davesav SQL Server ASP 2 June 10th, 2003 04:04 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.