By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,067 Members | 956 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,067 IT Pros & Developers. It's quick & easy.

Joining combobox value and 2 tables?

100+
P: 111
Hii all,

How to join two tables and a combobox value??

i have 2 combo boxes and 2 tables

i have aquery:

1)
Dim myselectquery As String = "SELECT pr_project_id_pk FROM tbl_projects WHERE tbl_projects.pr_project_location= ?SName"
cmSQL.Parameters.Add("?SName", objListItem.ToString)

and another query:
2)

Dim myselectquerya As String = "SELECT sta_category_id_fk FROM tbl_staff_assignments WHERE sta_project_id_fk=tbl_projects.pr_project_id_pk"


If sta_category_id_fk = 1 Then

MessageBox.Show("Already Available")

Else

Insert record
End If



now my doubt is: i need to join these two queries using joins....???? can u plz help me?

thnx in advance
hepsi..
Jul 11 '07 #1
Share this Question
Share on Google+
3 Replies


P: 99
Hii all,

How to join two tables and a combobox value??

i have 2 combo boxes and 2 tables

i have aquery:

1)
Dim myselectquery As String = "SELECT pr_project_id_pk FROM tbl_projects WHERE tbl_projects.pr_project_location= ?SName"
cmSQL.Parameters.Add("?SName", objListItem.ToString)

and another query:
2)

Dim myselectquerya As String = "SELECT sta_category_id_fk FROM tbl_staff_assignments WHERE sta_project_id_fk=tbl_projects.pr_project_id_pk"


If sta_category_id_fk = 1 Then

MessageBox.Show("Already Available")

Else

Insert record
End If



now my doubt is: i need to join these two queries using joins....???? can u plz help me?

thnx in advance
hepsi..
I can't get ur requirment..please explain what should be the result
and give ur table details
Jul 11 '07 #2

100+
P: 111
I can't get ur requirment..please explain what should be the result
and give ur table details


thnx for ur reply..

i have a form for staff insert

there are two combo boxes and a insert button_click
1. project name
2. categories name

in project name: i have list of projects namely:
1. abohar
2. ambedkar nagar

n so on...

in categories name: i hav list of categories
1.manager
2.HM
3.teacher
4.cook n so on....


now i have tables

1.tbl_projects,
2.tbl_staffs,
3.tbl_staff_assignments,
4.tbl_staff_categories

where tbl_projects:->> pr_project_location, pr_project_id_pk
tbl_staff_assignments:->>> sta_project_id_fk, sta_category_id_fk
tbl_staff_categories..>> sc_category_id_pk

for manager: sc_category_id_pk=1

Condition is: only 1 manager shd be inserted for 1 project...

Now when i select project name and category name,
if already manager is available in that project, then when i click on insert it shd pop up a error message tht manager is available..
or else it shd insert ....

that is my requirement..
i hope u understand

someone help me using joins....
hw to retrieve a combobox value...thru joins???
plz help me...


thnx
hepsi...
Jul 11 '07 #3

kenobewan
Expert 2.5K+
P: 4,871
Here is an article that may help:
SQL JOIN
Jul 11 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.