User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Visual Basic 4 / 5 / 6 section within the Software Development category of DaniWeb, a massive community of 391,666 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,878 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Visual Basic 4 / 5 / 6 advertiser:
Views: 996 | Replies: 4
Reply
Join Date: Jun 2007
Location: india /bangalore
Posts: 18
Reputation: ITech is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
ITech's Avatar
ITech ITech is offline Offline
Newbie Poster

how to write sql query to select from multiple tables in vb:help

  #1  
Apr 6th, 2008
hi

i aam trying to develop a project using vb and access

i have got a problem

i have 3 tables in access

1.Cust info table(fields are listed below)
cust id,name,age,sex,country...etcxc(primary key cust id)

2,indate(fields are listed below)
custid ,packageid,date,intime,outime(no primary key)

3.package info table(fields are listed below
package id, package name,duration ,price(primary key packageid)


tthese three tables are connected...the attachment shows how it is connected

i want to write a query to select custid, custname,packageid,packagename,duration,price,date,timein,timeout from these tables in vb..n in a data grid to display these.i know to write simple queries but this one i think it needs inner join n stuff..can any expert resolve my problem..
Attached Images
File Type: bmp relationship.bmp (445.7 KB, 9 views)
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Nov 2006
Posts: 692
Reputation: QVeen72 is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 94
QVeen72's Avatar
QVeen72 QVeen72 is offline Offline
Practically a Master Poster

Re: how to write sql query to select from multiple tables in vb:help

  #2  
Apr 6th, 2008
Hi,

Try this :

Select CI.name,I.ServiceID,P.packagename,P.duration,P.price,I.date,I.timeIn,I.timeOut
From CustInfo CI, InDate I, PakInfo P Where CI.CustID = I.CustID And I.ServiceID = P.ServiceID Order By CI.Name

Recheck all your Table and Field Names..

Regards
Veena
Reply With Quote  
Join Date: Jul 2008
Posts: 2
Reputation: hmehmi is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
hmehmi hmehmi is offline Offline
Newbie Poster

Re: how to write sql query to select from multiple tables in vb:help

  #3  
Jul 15th, 2008
This is sql statements works fine but id there any one who is having idea in how to use thisstatement in VB 2008
Reply With Quote  
Join Date: Nov 2007
Location: Jogja
Posts: 2,383
Reputation: Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light 
Rep Power: 9
Solved Threads: 206
Jx_Man's Avatar
Jx_Man Jx_Man is offline Offline
Nearly a Posting Maven

Re: how to write sql query to select from multiple tables in vb:help

  #4  
Jul 15th, 2008
post your code, its more easy to understand
Never tried = Never Know
So, Please do something before post your thread.
* PM Asking will be ignored *
Reply With Quote  
Join Date: Jul 2008
Posts: 2
Reputation: hmehmi is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
hmehmi hmehmi is offline Offline
Newbie Poster

Re: how to write sql query to select from multiple tables in vb:help

  #5  
Jul 15th, 2008
like in the following code what i am doing is if i push a button then it should choose next row from stud table and the scho should get the name from text1.text field and match in this table and should display the corrosponding row in scho table
 Dim connect_string As String = _
          "Provider=Microsoft.Jet.OLEDB.4.0;" & _
          "Data Source=""" & TextBox4.Text & """;" & _
          "Persist Security Info=False"
        Dim conn_test As New OleDb.OleDbConnection(connect_string)
        conn_test.Open()

        Dim cmd4 As New OleDbCommand("SELECT * FROM Stud ORDER BY Name", conn_test)

        Dim studAdap As New OleDbDataAdapter
        studAdap = New OleDbDataAdapter
        studAdap.SelectCommand = cmd4

        Dim studTab As DataTable
        studTab = New DataTable()
        studAdap.Fill(studTab)

        '' MaskedTextBox1.DataBindings.Add("text", studTab, "name")
        TextBox1.DataBindings.Add("Text", studTab, "name")
        TextBox2.DataBindings.Add("Text", studTab, "lname")
        TextBox3.DataBindings.Add("Text", studTab, "score")
        lblPhotoFile.DataBindings.Add("Text", studTab, "foto")
        studMgr = DirectCast(Me.BindingContext(studTab), CurrencyManager)
        Call ShowPhoto()
  Dim cmd5 As New OleDbCommand("SELECT * FROM scho WHERE scho.name =  '" & TextBox1.Text & "'", conn_test)
      

        Dim schoAdapa As New OleDbDataAdapter '*****
        schoAdapa = New OleDbDataAdapter
        schoAdapa.SelectCommand = cmd5

        Dim schoTaba As DataTable  '******
        schoTaba = New DataTable()
        schoAdapa.Fill(schoTaba)

        TextBox5.DataBindings.Add("Text", schoTaba, "school")
        TextBox6.DataBindings.Add("Text", schoTaba, "city")
        Label4.DataBindings.Add("Text", studTab, "foto")

        Call ShowFhoto()
Last edited by Tekmaven : Jul 15th, 2008 at 11:39 am. Reason: Code tags
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb Visual Basic 4 / 5 / 6 Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the Visual Basic 4 / 5 / 6 Forum

All times are GMT -4. The time now is 1:49 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC