473,394 Members | 1,774 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,394 software developers and data experts.

combo box that retrieve data from database in windows based application

Hi all,

I have to populate combo box that retrieve data from database in windows based application. I have two tables which are type and CD. Type has type ID and Category. CD has type ID as foreign key. When I will add a new CD, the user interface for user will show combo box to choose the category from combo box and the selected value should be saved as type ID.

First, I did a quarry in type dataset that will do search by type ID.

Now, I don’t know how to use this method to populate the category combo box in CD interface.


Any volunteer to help me.
Apr 15 '07 #1
11 2612
dwadish
129 100+
i am not clear with your problem. please simplify it.

i think you want to save a type id from the table which corresponding catagory you are selected from the list.

plz specify your question.

try
Apr 15 '07 #2
i am not clear with your problem. please simplify it.

i think you want to save a type id from the table which corresponding catagory you are selected from the list.

plz specify your question.

try

i think you want to save a type id from the table which corresponding catagory you are selected from the list.


This is what I mean. You understand correctly
Apr 15 '07 #3
dwadish
129 100+
first bind the category from the type table to combobox.

select the typeid from the table where catagory= combobox.text
assign the typeid to a variable.

insert the typeid(variable) into cd table.

try it now
Apr 15 '07 #4
Hi,


Could you provide me with example (Code ) for each step, please?

So that it can be cleared, because someone else has this problem. As a result, all body can benefit.


Your help is appreciated.


Thank you & Waiting to answer
Apr 17 '07 #5
dwadish
129 100+
Expand|Select|Wrap|Line Numbers
  1.  
  2.    USERDISPFORM_ LOAD()
  3.  OPEN THE DB CONECTION
  4.  
  5.   DIM DS AS NEW DATASET
  6. DIM adpt as New sqldataadapter("select catagory from type",con)
  7. adpt.fill(dt)
  8.  
  9. combo1.datasource=dt.tables(0)
  10. combo1.displaymember="catagory"
  11.  
  12. close connection
  13. end sub
  14.  
  15.  select any  event you like
  16.  
  17.                button1_clik( )
  18. open connection
  19.  
  20. dim cmd as new sqlcommand("select typeid from type where catagory='"& combo1.text &"' ",con)
  21.  
  22. dim dr as sqldatareader
  23. dr=cmd.exicutereader
  24. dim s as string
  25. while dr.read
  26. s=dr.getvalue(0)
  27. end while
  28.  
  29. dr.close
  30. dim cmd2 as new sqlcommand("insert into cd values('"& s &"')",con)
  31. dim dr as sqldatareader
  32. dr=cmd2.exicutenonquery
  33. dr.close
  34. close connection
  35.  
try it now
Apr 18 '07 #6
Expand|Select|Wrap|Line Numbers
  1.  
  2.    USERDISPFORM_ LOAD()
  3.  OPEN THE DB CONECTION
  4.  
  5.   DIM DS AS NEW DATASET
  6. DIM adpt as New sqldataadapter("select catagory from type",con)
  7. adpt.fill(dt)
  8.  
  9. combo1.datasource=dt.tables(0)
  10. combo1.displaymember="catagory"
  11.  
  12. close connection
  13. end sub
  14.  
  15.  select any  event you like
  16.  
  17.                button1_clik( )
  18. open connection
  19.  
  20. dim cmd as new sqlcommand("select typeid from type where catagory='"& combo1.text &"' ",con)
  21.  
  22. dim dr as sqldatareader
  23. dr=cmd.exicutereader
  24. dim s as string
  25. while dr.read
  26. s=dr.getvalue(0)
  27. end while
  28.  
  29. dr.close
  30. dim cmd2 as new sqlcommand("insert into cd values('"& s &"')",con)
  31. dim dr as sqldatareader
  32. dr=cmd2.exicutenonquery
  33. dr.close
  34. close connection
  35.  
try it now


Hi,


Thank you a lot Mr. dwadish for hepling and its works

This is because, you helped me a lot to over come this problem which stop me to complete my project.


Wish you a good luck.



Aisha
Apr 21 '07 #7
dwadish
129 100+
Welcome !! Aisha

which project you are doing. or for what
Apr 21 '07 #8
Welcome !! Aisha

which project you are doing. or for what

it's for company friend.
Apr 24 '07 #9
dwadish
129 100+
sorry best of luck.

i am a student of mcsd.net .

===============================
Apr 24 '07 #10
sorry best of luck.

i am a student of mcsd.net .

===============================

Thank you


I wish you a good luck toooooooo
Apr 29 '07 #11
dwadish
129 100+
Thank you


I wish you a good luck toooooooo
now i am MCAD.NET

Thanx
Apr 30 '07 #12

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

Similar topics

0
by: Smith_X | last post by:
I have access database which I willuse form to retrieve a field to show in List of combo box. the method that I use now is adodb code when form load is show below. Private Sub Form_Load() Dim...
7
by: Megan | last post by:
Hi everybody- I inherited a database that somehow uses a bound combo box as a record selector. Let me give you some background. The form is based on data from 2 tables. The first table, Person,...
3
by: Neil Guyette | last post by:
Hello, Everyone, I'm trying to find information on how to populate a combo box using a SqlDataReader. I want to be able to set the value of the combo's value property different then the...
2
by: Stefke | last post by:
Hi, I want to write a little application with a textbox in which I can enter a systems host name or ip address. After clicking on a button Get Info, I want to display an overview of the systems...
6
by: Jean Christophe Avard | last post by:
Hi! I'm designing an application that produces invoices. I have a combobox that is populated with the Name of every client in the database. What I would like to do is to have the combobox to...
3
by: rlm | last post by:
This small problem to solve involves a two table database (one parent and one child table), one winform and two combo boxes. Combo box A is populated in the Load event. Combo box A pulls data...
0
by: northshore | last post by:
Hello, I am creating a windows application database. I have a primary table 'Individuals' and a lookup table 'Prefixes.' In the Individuals table, I have a column 'PrefixID' that references...
2
by: biganthony via AccessMonster.com | last post by:
Hi, I decided to install Office 2003 Service Pack 3 on my home computer to test (in full knowledge that there may be some issues with it). After installation, I have noticed that with a small...
30
ADezii
by: ADezii | last post by:
This week’s Tip of the Week will clearly demonstrate how you can dynamically set the Drop Down List Width of a Combo Box to the length of the longest item in its Row Source. The inspiration for this...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.