How to populate default values from database in combo and text box at Form load(Run time)event?

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hi Friends,
<p style="padding-right:0px; font-size:14px; vertical-align:baseline; clear:both; word-wrap:break-word; font-family:Arial,Liberation Sans,DejaVu Sans,sans-serif
I need to display default values in combo and text boxes from database whenever form load event happens.
<p style="padding-right:0px; font-size:14px; vertical-align:baseline; clear:both; word-wrap:break-word; font-family:Arial,Liberation Sans,DejaVu Sans,sans-serif
I have below 2 tables:
<p style="padding-right:0px; font-size:14px; vertical-align:baseline; clear:both; word-wrap:break-word; font-family:Arial,Liberation Sans,DejaVu Sans,sans-serif
1st Employee table:
<pre class="x_x_default x_x_prettyprint x_x_prettyprinted" style="padding:5px; border:0px; font-size:14px; vertical-align:baseline; background-color:#eeeeee; font-family:Consolas,Menlo,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New,monospace,serif; width:auto; max-height:600px <code style="margin:0px; padding:0px; border:0px; font-size:14px; vertical-align:baseline; font-family:Consolas,Menlo,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New,monospace,serif <span class="typ" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#2b91af EmpID<span class="pln" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent
<span class="typ" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#2b91af EName<span class="pln" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent
<span class="typ" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#2b91af ESalary<span class="pln" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent
<span class="typ" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#2b91af EDept[/code][/code]
<p style="padding-right:0px; font-size:14px; vertical-align:baseline; clear:both; word-wrap:break-word; font-family:Arial,Liberation Sans,DejaVu Sans,sans-serif
2nd Employee table data:
<pre class="x_x_default x_x_prettyprint x_x_prettyprinted" style="padding:5px; border:0px; font-size:14px; vertical-align:baseline; background-color:#eeeeee; font-family:Consolas,Menlo,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New,monospace,serif; width:auto; max-height:600px <code style="margin:0px; padding:0px; border:0px; font-size:14px; vertical-align:baseline; font-family:Consolas,Menlo,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New,monospace,serif <span class="lit" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#800000 001<span class="pln" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent
<span class="typ" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#2b91af John<span class="pln" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent
<span class="lit" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#800000 1000<span class="pln" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent
<span class="typ" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#2b91af Sales<span class="pln" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent

<span class="lit" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#800000 002<span class="pln" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent
<span class="typ" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#2b91af Tony<span class="pln" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent
<span class="lit" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#800000 2000<span class="pln" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent
<span class="typ" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#2b91af Production<span class="pln" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent

<span class="lit" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#800000 003<span class="pln" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent
<span class="typ" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#2b91af Troy<span class="pln" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent
<span class="lit" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#800000 3000<span class="pln" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent
<span class="typ" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#2b91af Marketing[/code][/code]
<p style="padding-right:0px; font-size:14px; vertical-align:baseline; clear:both; word-wrap:break-word; font-family:Arial,Liberation Sans,DejaVu Sans,sans-serif
I need to display <code style="margin:0px; padding:1px 5px; border:0px; font-size:14px; vertical-align:baseline; background-color:#eeeeee; font-family:Consolas,Menlo,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New,monospace,serif Ename[/code], <code style="margin:0px; padding:1px 5px; border:0px; font-size:14px; vertical-align:baseline; background-color:#eeeeee; font-family:Consolas,Menlo,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New,monospace,serif ESalary[/code] and <code style="margin:0px; padding:1px 5px; border:0px; font-size:14px; vertical-align:baseline; background-color:#eeeeee; font-family:Consolas,Menlo,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New,monospace,serif Edept[/code] data
in combo box with default name: John, default Esalary: 1000 and default Edept Sales.
<p style="padding-right:0px; font-size:14px; vertical-align:baseline; clear:both; word-wrap:break-word; font-family:Arial,Liberation Sans,DejaVu Sans,sans-serif
I have design form in studio 2010 using VB.Net where Ename, Esalary and Edept are in labels and for John, 1000 and Sales I have combo box like below:
<pre class="x_x_default x_x_prettyprint x_x_prettyprinted" style="padding:5px; border:0px; font-size:14px; vertical-align:baseline; background-color:#eeeeee; font-family:Consolas,Menlo,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New,monospace,serif; width:auto; max-height:600px <code style="margin:0px; padding:0px; border:0px; font-size:14px; vertical-align:baseline; font-family:Consolas,Menlo,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New,monospace,serif <span class="typ" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#2b91af Lables<span class="pun" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#000000 :<span class="pln" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent <span class="typ" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#2b91af Combo<span class="pln" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent box<span class="pun" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#000000 :<span class="pln" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent

<span class="typ" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#2b91af Ename<span class="pun" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#000000 :<span class="pln" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent <span class="typ" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#2b91af John<span class="pln" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent <span class="pun" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#000000 (<span class="typ" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#2b91af Default<span class="pun" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#000000 ) and followed by other values in it.<span class="pln" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent
<span class="typ" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#2b91af ESalary<span class="pun" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#000000 :<span class="pln" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent <span class="lit" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#800000 1000<span class="pln" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent <span class="pun" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#000000 (<span class="typ" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#2b91af Default<span class="pun" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#000000 ) <span class="pln" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent
<span class="typ" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#2b91af EDept<span class="pun" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#000000 :<span class="pln" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent <span class="typ" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#2b91af Sales<span class="pln" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent <span class="pun" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#000000 (<span class="typ" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#2b91af Default<span class="pun" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background-color:transparent; color:#000000 ) [/code][/code]
<p style="padding-right:0px; font-size:14px; vertical-align:baseline; clear:both; word-wrap:break-word; font-family:Arial,Liberation Sans,DejaVu Sans,sans-serif
My Question is: How would I display above mentioned default values in combo box followed by other data when form load event happens? (If I need to pick other values in Ename, ESalary or Edept I can pick from Combo box otherwise by default It will pop up only
John, 1000 and Sales.
<p style="padding-right:0px; font-size:14px; vertical-align:baseline; clear:both; word-wrap:break-word; font-family:Arial,Liberation Sans,DejaVu Sans,sans-serif
I am new to VB.Net and sorry If I am not able to explain it in proper way or asking simple thing.
<p style="padding-right:0px; font-size:14px; vertical-align:baseline; clear:both; word-wrap:break-word; font-family:Arial,Liberation Sans,DejaVu Sans,sans-serif
I would appreciate any help into this. Thanks a lot in advance :)
<br/>

<br/>

View the full article
 
Back
Top