473,386 Members | 1,819 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

How to write a code for selected item in a combo box

111 100+
hii all,

for selecting one item in a combo box n writing a search button_click code for that....

There are 3 items in teh combobox, nw for 1 item i want to write a code for search_button click

How to start with

If combobox = Project Manager Then................>> error

wat shd i consider...

plz someone help...

thnx
Jul 5 '07 #1
14 2444
Vidhura
99
hii all,

for selecting one item in a combo box n writing a search button_click code for that....

There are 3 items in teh combobox, nw for 1 item i want to write a code for search_button click

How to start with

If combobox = Project Manager Then................>> error

wat shd i consider...

plz someone help...

thnx
in Combobox

Could you explain more?What is your requirment?
Jul 5 '07 #2
r035198x
13,262 8TB
hii all,

for selecting one item in a combo box n writing a search button_click code for that....

There are 3 items in teh combobox, nw for 1 item i want to write a code for search_button click

How to start with

If combobox = Project Manager Then................>> error

wat shd i consider...

plz someone help...

thnx
Do you mean that you want to call the same actions in the method button_click when option 1 is selected?
Which language are you using? e.g in C# :
to test the value selected on the combobox you use
Expand|Select|Wrap|Line Numbers
  1. if (this.combobox .Text == "Project Manager") 
Jul 5 '07 #3
rhepsi
111 100+
Do you mean that you want to call the same actions in the method button_click when option 1 is selected?
Which language are you using? e.g in C# :
to test the value selected on the combobox you use
Expand|Select|Wrap|Line Numbers
  1. if (this.combobox .Text == "Project Manager") 
thnx for ur reply...

i have 3 items... i want to write in the search_button_click for 3rd option...
im using vb.net 1.1...

plz help..
Jul 5 '07 #4
rhepsi
111 100+
in Combobox

Could you explain more?What is your requirment?
hii,

i have 2 comboboxes...one for select category(3items: project code, project location, project manager) and 2nd combobox for search list( where im populating the code, location and manager )
here im populating the records for code n location from tbl_projects (db) whereas for manager i need from tbl_staffs and tbl_staff_assignments(where category for manager is present)...

i hope u understand...

nw i have search button,

in this, i can search the records by project_id_pk...(tbl_projects)


[vb.net code] for search_button_click


' Get Primary Key from Listbox
objListItem = CType(cbPrSearchList.SelectedItem, ListItem)

cmSQL = New MySqlCommand




Dim mySelectQuery As String = "Select pr_project_id_pk, pr_project_code, pr_project_location, --etc " _
& "from tbl_projects where pr_project_id_pk= ?PrID"


cmSQL.Parameters.Add("?PrId", objListItem.ID)

[/code]

nw my doubt is i dont want to take list item, rather single ones...

how and wat shd be my code..???

plz help..

thnx n regards
hepsi..
Jul 5 '07 #5
prabunewindia
199 100+
hi friend,
i am not getting u.
give ur table details and combox and for what u r using the same and
what u need as ur output?
plz be clear
prabu


hii,

i have 2 comboboxes...one for select category(3items: project code, project location, project manager) and 2nd combobox for search list( where im populating the code, location and manager )
here im populating the records for code n location from tbl_projects (db) whereas for manager i need from tbl_staffs and tbl_staff_assignments(where category for manager is present)...

i hope u understand...

nw i have search button,

in this, i can search the records by project_id_pk...(tbl_projects)


[vb.net code] for search_button_click


' Get Primary Key from Listbox
objListItem = CType(cbPrSearchList.SelectedItem, ListItem)

cmSQL = New MySqlCommand




Dim mySelectQuery As String = "Select pr_project_id_pk, pr_project_code, pr_project_location, --etc " _
& "from tbl_projects where pr_project_id_pk= ?PrID"


cmSQL.Parameters.Add("?PrId", objListItem.ID)

[/code]

nw my doubt is i dont want to take list item, rather single ones...

how and wat shd be my code..???

plz help..

thnx n regards
hepsi..
Jul 5 '07 #6
Vidhura
99
hii,

i have 2 comboboxes...one for select category(3items: project code, project location, project manager) and 2nd combobox for search list( where im populating the code, location and manager )
here im populating the records for code n location from tbl_projects (db) whereas for manager i need from tbl_staffs and tbl_staff_assignments(where category for manager is present)...

i hope u understand...

nw i have search button,

in this, i can search the records by project_id_pk...(tbl_projects)


[vb.net code] for search_button_click


' Get Primary Key from Listbox
objListItem = CType(cbPrSearchList.SelectedItem, ListItem)

cmSQL = New MySqlCommand




Dim mySelectQuery As String = "Select pr_project_id_pk, pr_project_code, pr_project_location, --etc " _
& "from tbl_projects where pr_project_id_pk= ?PrID"


cmSQL.Parameters.Add("?PrId", objListItem.ID)

[/code]

nw my doubt is i dont want to take list item, rather single ones...

how and wat shd be my code..???

plz help..

thnx n regards
hepsi..
Still I couldnt get you

My understanding:

Combobox1 has following 3 items

1.ProjectCode
2.ProjectLocation
3.ProjectManager

Combobox 2 is empty

If you select ProjectManager in combobox1 all the projectmangers should be listed in Combobox2...

in button clickevent

if (this.combobox .selectedItem == "ProjectManager")
query="select distinct staffname from tbl_staff "

is this your requirment?
Jul 5 '07 #7
rhepsi
111 100+
Still I couldnt get you

My understanding:

Combobox1 has following 3 items

1.ProjectCode
2.ProjectLocation
3.ProjectManager

Combobox 2 is empty

If you select ProjectManager in combobox1 all the projectmangers should be listed in Combobox2...

in button clickevent

if (this.combobox .selectedItem == "ProjectManager")
query="select distinct staffname from tbl_staff "

is this your requirment?

thnx for ur reply...

no thts not my requirement..

my requirement is:
combobox2 is not empty..
.combobox2:
1. abc
2.xyz
3.fdf;
so on. till 52

in the form i have a search button ...
when i select project manager from1st combobox, all the managers are populated in the 2nd combobox....(this is frm tbl_staffs)

nw when i click on search,
search is doin its operation in tbl_projects like
the list of managers tht r present in the combobox's primary key = tbl_projects primary key
that means it is not goin to tbl_staffs but rather tbl_projects
i hope u understand...
i need a help for writing a separate query for tbl_staffs for the project manager..

thnx
hepsi..
Jul 5 '07 #8
prabunewindia
199 100+
be clear my friend!
what u want to search?
what is table project contains?
give details about both table.
what result u r expecting?

thnx for ur reply...

no thts not my requirement..

my requirement is:
combobox2 is not empty..
.combobox2:
1. abc
2.xyz
3.fdf;
so on. till 52

in the form i have a search button ...
when i select project manager from1st combobox, all the managers are populated in the 2nd combobox....(this is frm tbl_staffs)

nw when i click on search,
search is doin its operation in tbl_projects like
the list of managers tht r present in the combobox's primary key = tbl_projects primary key
that means it is not goin to tbl_staffs but rather tbl_projects
i hope u understand...
i need a help for writing a separate query for tbl_staffs for the project manager..

thnx
hepsi..
Jul 5 '07 #9
Vidhura
99
thnx for ur reply...

no thts not my requirement..

my requirement is:
combobox2 is not empty..
.combobox2:
1. abc
2.xyz
3.fdf;
so on. till 52

in the form i have a search button ...
when i select project manager from1st combobox, all the managers are populated in the 2nd combobox....(this is frm tbl_staffs)

nw when i click on search,
search is doin its operation in tbl_projects like
the list of managers tht r present in the combobox's primary key = tbl_projects primary key
that means it is not goin to tbl_staffs but rather tbl_projects
i hope u understand...
i need a help for writing a separate query for tbl_staffs for the project manager..

thnx
hepsi..
You want to list the projectcode and projectlocation for the projectmanager you selected in the Combobox2.Is this right?

If yes,give your table_staff,table_staff_assignment,table_project structures(fields present in the table)

sample query:

select C.ID,C.ProjectCode,C.ProjectLocation,C.ProjectName from tbl_staff A
left join tbl_staff _assignments B on B.StaffID=A.ID
left join tbl_projects C on C.ID=B.projectID
where A.Name=(combobox.selecteditem)
Jul 5 '07 #10
rhepsi
111 100+
You want to list the projectcode and projectlocation for the projectmanager you selected in the Combobox2.Is this right?

If yes,give your table_staff,table_staff_assignment,table_project structures(fields present in the table)

sample query:

select C.ID,C.ProjectCode,C.ProjectLocation,C.ProjectName from tbl_staff A
left join tbl_staff _assignments B on B.StaffID=A.ID
left join tbl_projects C on C.ID=B.projectID
where A.Name=(combobox.selecteditem)

thnq so much... i shall try tht code... n give u reply...
Jul 6 '07 #11
rhepsi
111 100+
You want to list the projectcode and projectlocation for the projectmanager you selected in the Combobox2.Is this right?

If yes,give your table_staff,table_staff_assignment,table_project structures(fields present in the table)

sample query:

select C.ID,C.ProjectCode,C.ProjectLocation,C.ProjectName from tbl_staff A
left join tbl_staff _assignments B on B.StaffID=A.ID
left join tbl_projects C on C.ID=B.projectID
where A.Name=(combobox.selecteditem)


Hey ive tried it.... but of no use...
here is my code:
Expand|Select|Wrap|Line Numbers
  1.         ' Get Primary Key from Listbox
  2.         objListItem = CType(cbPrSearchList.SelectedItem, ListItem)
  3.  
  4.         cmSQL = New MySqlCommand
  5.  
  6.         Dim mySelectQuery As String = "Select pr_project_id_pk, pr_project_code," _
  7.         & "pr_project_location, pr_project_manager_id_fk, pr_street_address, " _
  8.         & "pr_state_id_fk, pr_pincode, pr_postal_address, pr_phone, " _
  9.         & "pr_courier_service, pr_email, pr_om_field, pr_total_students, pr_total_staff, " _
  10.         & "pr_teaching_staff, pr_non_teaching_staff, pr_project_background, " _
  11.         & "pr_profile_status, pr_photo_status, pr_upload_status, pr_comm_history" _
  12.         & "from tbl_staffs INNER JOIN tbl_staff_assignments ON tbl_staff_assignments.sta_staff_id_fk = tbl_staffs.stf_staff_id_pk " _
  13.         & "INNER JOIN tbl_projects ON tbl_projects.pr_project_id_pk = tbl_staff_assignments.sta_project_id_fk " _
  14.         & "WHERE tbl_staff_assignments.sta_project_id_fk = ?StId"
  15.  
  16.  
  17.         cmSQL.Parameters.Add("?StId", objListItem.ID)
  18.  
  19.         cnSQL = New MySqlConnection
  20.         cnSQL.ConnectionString = connect.ConnectionString
  21.  
  22.         cmSQL.Connection = cnSQL
  23.         cmSQL.CommandText = mySelectQuery
  24.  
  25.  
Its takingdirectly the project_id from tbl_projects not from tbl_staff_assignments project_id...

plz if u can help me...
Jul 9 '07 #12
rhepsi
111 100+
Hey ive tried it.... but of no use...
here is my code:
Expand|Select|Wrap|Line Numbers
  1.         ' Get Primary Key from Listbox
  2.         objListItem = CType(cbPrSearchList.SelectedItem, ListItem)
  3.  
  4.         cmSQL = New MySqlCommand
  5.  
  6.         Dim mySelectQuery As String = "Select pr_project_id_pk, pr_project_code," _
  7.         & "pr_project_location, pr_project_manager_id_fk, pr_street_address, " _
  8.         & "pr_state_id_fk, pr_pincode, pr_postal_address, pr_phone, " _
  9.         & "pr_courier_service, pr_email, pr_om_field, pr_total_students, pr_total_staff, " _
  10.         & "pr_teaching_staff, pr_non_teaching_staff, pr_project_background, " _
  11.         & "pr_profile_status, pr_photo_status, pr_upload_status, pr_comm_history" _
  12.         & "from tbl_staffs INNER JOIN tbl_staff_assignments ON tbl_staff_assignments.sta_staff_id_fk = tbl_staffs.stf_staff_id_pk " _
  13.         & "INNER JOIN tbl_projects ON tbl_projects.pr_project_id_pk = tbl_staff_assignments.sta_project_id_fk " _
  14.         & "WHERE tbl_staff_assignments.sta_project_id_fk = ?StId"
  15.  
  16.  
  17.         cmSQL.Parameters.Add("?StId", objListItem.ID)
  18.  
  19.         cnSQL = New MySqlConnection
  20.         cnSQL.ConnectionString = connect.ConnectionString
  21.  
  22.         cmSQL.Connection = cnSQL
  23.         cmSQL.CommandText = mySelectQuery
  24.  
  25.  
Its takingdirectly the project_id from tbl_projects not from tbl_staff_assignments project_id...

plz if u can help me...
Im getting this error


Dim mySelectQuery As String = "Select pr_project_id_pk, pr_project_code," _
& "pr_project_location, pr_project_manager_id_fk, pr_street_address, " _
& "pr_state_id_fk, pr_pincode, pr_postal_address, pr_phone, " _
& "pr_courier_service, pr_email, pr_om_field, pr_total_students, pr_total_staff, " _
& "pr_teaching_staff, pr_non_teaching_staff, pr_project_background, " _
& "pr_profile_status, pr_photo_status, pr_upload_status, pr_comm_history, " _
& "pr_cs_comments, pr_lkg, pr_ukg, pr_class01, pr_class02, pr_class03, " _
& "pr_class04, pr_class05, pr_class06, pr_class07, pr_class08, pr_class09, " _
& "pr_class10, pr_year_started , pr_land_status, pr_building_status, " _
& "pr_ann_op_cost, pr_project_remarks, pr_info_date, pr_isactive " _
& "FROM tbl_staffs LEFT JOIN tbl_staff_assignments ON tbl_staff_assignments.sta_staff_id_fk = tbl_staffs.stf_staff_id_pk " _
& "LEFT JOIN tbl_projects ON tbl_projects.pr_project_id_pk = tbl_staff_assignments.sta_project_id_fk " _
& "WHERE tbl_staffs.stf_first_name = ?SID "


cmSQL.Parameters.Add("?SID", objListItem.ID)


General Error

Cast from string "" to type 'Double' is not valid.
Jul 9 '07 #13
Vidhura
99
Im getting this error


Dim mySelectQuery As String = "Select pr_project_id_pk, pr_project_code," _
& "pr_project_location, pr_project_manager_id_fk, pr_street_address, " _
& "pr_state_id_fk, pr_pincode, pr_postal_address, pr_phone, " _
& "pr_courier_service, pr_email, pr_om_field, pr_total_students, pr_total_staff, " _
& "pr_teaching_staff, pr_non_teaching_staff, pr_project_background, " _
& "pr_profile_status, pr_photo_status, pr_upload_status, pr_comm_history, " _
& "pr_cs_comments, pr_lkg, pr_ukg, pr_class01, pr_class02, pr_class03, " _
& "pr_class04, pr_class05, pr_class06, pr_class07, pr_class08, pr_class09, " _
& "pr_class10, pr_year_started , pr_land_status, pr_building_status, " _
& "pr_ann_op_cost, pr_project_remarks, pr_info_date, pr_isactive " _
& "FROM tbl_staffs LEFT JOIN tbl_staff_assignments ON tbl_staff_assignments.sta_staff_id_fk = tbl_staffs.stf_staff_id_pk " _
& "LEFT JOIN tbl_projects ON tbl_projects.pr_project_id_pk = tbl_staff_assignments.sta_project_id_fk " _
& "WHERE tbl_staffs.stf_first_name = ?SID "


cmSQL.Parameters.Add("?SID", objListItem.ID)


General Error

Cast from string "" to type 'Double' is not valid.

& "WHERE tbl_staffs.stf_first_name = ?SID "


cmSQL.Parameters.Add("?SID", objListItem.ID)

what the objectlistItem.ID contains?either staffname or ID

If you connecting with ID

use
& "WHERE tbl_staffs.ID= ?SID "
Jul 9 '07 #14
rhepsi
111 100+
& "WHERE tbl_staffs.stf_first_name = ?SID "


cmSQL.Parameters.Add("?SID", objListItem.ID)

what the objectlistItem.ID contains?either staffname or ID

If you connecting with ID

use
& "WHERE tbl_staffs.ID= ?SID "

hey thnq so much... its workin nw...
Jul 9 '07 #15

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

Similar topics

1
by: Donna Sabol | last post by:
I have a form (frm_MAIN_RPT) that contains a combo box (Combo6) & subform (dbo_REQ_subform). The combo box is used to select the "cost center" data that will be displayed in the subform. From...
1
by: ree | last post by:
I have two combo boxes on a dialog window. The aim is to check the the strings of the items. But if no items are selected then this line crashes the program. if...
2
by: Stephen Miller | last post by:
When I dynamically populate a HtmlSelect combo box, the Value property consistently fails to return the item selected, defaulting instead to the first item in the list. For example: Protected...
1
by: jimb | last post by:
I can get the dropdownlist into the datagrid, and I can populate it, but I can't read it. Anybody have a working example of a dropdownlist in an editable grid? Thanks. -- .....
2
by: Brian Henry | last post by:
say I have a databound combo box, which allows for text entry still (DropDownStype = DropDown in this case). now, If the user doesn't enter manually an item in the data bound list, nothing...
6
by: Smokey Grindle | last post by:
Say I have a combo box with the following simple object Public class MyObject public ID as integer public Name as string public overrides sub ToString() as string return name end sub end...
16
Ranjan kumar Barik
by: Ranjan kumar Barik | last post by:
Hello !!! I am Ranjan. can the selected item of a combo box be displayed on the same page. I mean when I just click the item of a combo box it will atonce displayed on the page. Thanks !!!
14
by: Just_a_fan | last post by:
In VB6, I could easily take the value from a combo box and make a command with it, this: baudrate = cboBaud(listindex). With the new dotted stuff in VB9, I can't seem to do that. Here's an...
8
by: ZaphodBBB | last post by:
Hi I have a form frmAdd_Equipment. It has a number of combo boxes on it, cboModel, cboSupplier, cboManufacturer, cboEquipment_Type etc. Bcause therer is no existing data to go off I put an ADD...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.