Database Values in Textbox based on combobox

I'm trying to display some information in a textbox that relates to the data of the field selected in the combo box currently I have no errors except when I select a different name from the combo box the data in my textbox does not change and stays on a
random name/address selected from the database. Hope that makes sense, here is my code as I guess it will explain things better
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
// Create SQL String
string queryString = "SELECT * FROM tblDrs where fldSName= '" + comboBox1.Text + "'; ";
// Create the instances
OleDbDataReader dbReader;
OleDbConnection dbConnect;
OleDbCommand dbCommand;
// Call the instances
try
dbConnect = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source =New DrsReqForms_2k_2013-03-15.mdb");
dbCommand = new OleDbCommand("SELECT * FROM tblDrs", dbConnect);
dbConnect.Open();
dbReader = dbCommand.ExecuteReader();
while (dbReader.Read())
string sName = dbReader["fldGiven Names"].ToString();
string sAddress = dbReader["fldAdd1"].ToString();
txtInitials.Text = sName;
txtAddress.Text = sAddress;
catch (Exception ex)
MessageBox.Show(ex.Message);

I notice.
string queryString = "SELECT * FROM tblDrs where fldSName= '" + comboBox1.Text + "'; ";
and
dbCommand = new OleDbCommand("SELECT * FROM tblDrs", dbConnect);
Maybe that second one is there just because the first wasn't working or something.
I would think though that you will get a whole bunch of records and your reader will loop through every one.  Whichever is last is what you get to see and that could well be random.
That first line looks rather more like it'd work, but you're not using that at all.
Nothing really just jumps out at me other than that.
You should be doing the
Using( create connection)
 // use the connection
But that's a different sort of issue.
The thing I would do here is insert a break point and see what is happening.
This is a key skill for any developer - get used to working that way ASAP.
http://social.technet.microsoft.com/wiki/contents/articles/29181.msdn-forums-asking-questions.aspx#Debugging
Hope that helps.
Technet articles: Uneventful MVVM;
All my Technet Articles
Thanks so much, this made total sense when I had another look at the code, it was indeed looping right to the end field until I removed the string and updated the command query.

Similar Messages

  • Can't post multiple values using forms based on procedure

    I want to post multiple values from form based on procedure. Is it possible?
    I've tried following steps:
    - create LOV with Multiple Values format
    - create form based on procedure
    - in Formatting and Validation page choose required item
    - select item type - combobox, enter input height = 5
    - select my LOV for item
    after creating form I get listbox, but selecting multiple values (with Ctrl or Shift key) not working...
    what's wrong.
    I'm use portal 9.0.2.2.22

    Hi,
    It is not possbile right now with Portal Forms to submit multiple values to a field.
    Thanks,
    Sharmila

  • How to display the contents of the database values which are retrived.

    how to display the contents of the database values which are retrived in servlets and i am able to display the contents in the servlets and if forward to jsp using requestdespatcher,the values are to be shown in jsp one below the other.please suggest me in these........the servlet code is as shown
    while(rs.next()){
                        buffer.append(rs.getString(1));
                        buffer.append(rs.getString(2));
                        buffer.append(rs.getString(3));
                        buffer.append(rs.getString(4));
                        buffer.append(rs.getString(5));
                        buffer.append(rs.getString(6));
                        buffer.append(rs.getString(7));
                        buffer.append(rs.getString(8));
                        buffer.append(rs.getString(9));
                        buffer.append(rs.getString(10));
                        request.setAttribute("result1",buffer);
                        RequestDispatcher rq=request.getRequestDispatcher("/results.jsp");
                        rq.forward(request,response);
    in jsp iam using the getAttribute to retrieve the values as shown
    <% StringBuffer sb=(StringBuffer)request.getAttribute("result1"); %>
    <%= sb %>
    but getting the results in the stretch,i need to display the result one below the other.

    if you load it all into the buffer that is going to be very difficult. I would suggest loading it into some sort of collection. I like using an ArrayList.
    Then pass the arraylist.
    you will then on the jsp iterate through the arrayList using what every you want.. el, logic tags, scriplets.
    so something like
    ArrayList arrayList = new ArrayList();
    while(rs.next()){
    arrayList.append(rs.getString(1));
    //or possibly an arrayList of String arrays
    //maybe using nested for loops.  Inner for loop adds result to string[] then //outer adds string[] to arrayList.
    //can be done any number of ways based on your expected result set.

  • How can I know the database is using Cost Based or Rule Based?

    Hi all expertise,
    How can I know the database is using Cost Based or Rule Based?
    If cost based it is using, what methods are need to use to minimize the cost when database is running? And which tables I can see the performance of the database?
    Thanks
    Amy

    how to see database setting ?
    use this
    SQL> sho parameter optimizer
    NAME TYPE VALUE
    optimizer_dynamic_sampling integer 1
    optimizer_features_enable string 9.2.0
    optimizer_index_caching integer 0
    optimizer_index_cost_adj integer 100
    optimizer_max_permutations integer 2000
    optimizer_mode string CHOOSE
    choose means if table statistics is available then it will use cost
    else
    use rule based optimizer
    for seeing performnace of table use
    set autotrace on
    and run your query
    if it doen't show cost.it means it use rule based
    for using cost based
    u will calculate table statistics
    9i
    dbms_stats.gather_table_stats('owner','table');
    8i
    analyze table <table_name> compute statistics;
    hope it will help you
    kuljeet pal singh

  • How to get check value in DB based on java

    hi,
    anybody know how to get check value in DB based on java?
    TQ

    This should be a custom java class containing that method.
    Try on java or jdbc forum - Java Database Connectivity (JDBC) , Java Programming

  • How to check radio button as default on the basis of database value?

    Hi Friends,
    I have one jsp, in which I am having a field of radio button, which have two boolean values of 0 & 1. I want to check the radio button as default on the basis of database value, kindly help me out.
    Thanks a lot in advance. Please help me out.

    probably, when using struts you should do all your calculations in action class it self
    Eg. in jsp
    <html:radio name="myForm" property="myProperty" value="0">0</html:radio>
    <html:radio name="myForm" property="myProperty" value="1">1</html:radio>
    in Action class
    if (databaseValue == 0)myForm.setMyProperty(0);
    else if (databaseValue == 1)myForm.setMyProperty(1);
    rest will follow
    whatever be the value it will come selected

  • How to populate value into textboxes

    Hi,
    I'm working with oracle forms for portlet and need help populating a certain value into textboxes. There are 40 textboxes, 40 checkboxes, and a textbox for a user to enter a value. When a user checks the preferred checkboxes then enters the value into the textbox, I want this value to be populated into those 40 textboxes.
    Please help...
    Thx in advance,
    Thuly2

    Hi Adi
    If ZVal is your value node then,
      DATA: lref_entity    TYPE REF TO cl_bsp_wd_value_node,
            lref_bo_coll   TYPE REF TO if_bol_bo_col,
            lref_data TYPE REF TO <<your ZStructure>>,
             ls_data type <<your ZStructure>>.
    ls_data-<<field1>> = 'XYZ'
    ls_data-<<field2>> = 'XYZ'
         CREATE OBJECT lref_bo_coll TYPE cl_crm_bol_bo_col.
          CREATE DATA lref_data.
          CREATE OBJECT lref_entity
            EXPORTING
              iv_data_ref = lref_data.
          lref_entity->set_properties( ls_data ).
          lref_bo_coll->add( lref_entity ).
          typed_context->ZVal->set_collection( lref_bo_coll ).
    Hope this was helpful.
    Best Regards,
    Lakshminarayana

  • How to store all database values in to a single textarea in swing

    I am trying to show my database values in to a single textarea but i cannot able to show to that textarea.. pls someone help..

    I am not shure what you are exactly meaning but you can use the setText(String text) method of JTextArea.
    Several values could be seperated with a "\n" character.
    import javax.swing.*;
    public class ImplodeTrial {
      public static void main(String[] args) {
          String[] databaseValues={"Apple", "Banana", "Orange"};
          String temp=implode(databaseValues, "\n");
          JTextArea t=new JTextArea();
           t.setText(temp);     
          JFrame j=new JFrame();
           j.getContentPane().add(t);
           j.pack();
           j.setVisible(true);
       public static String implode(String[] ary, String delim) {
             String out = "";
             for(int i=0; i<ary.length; i++) {
                 if(i!=0) { out += delim; }
                 out += ary;
         return out;

  • Default value of prompt based on another request

    Hello:
    I have a requirement where I need to set default values of prompts based on another request.
    The prompt is a Date Prompt.
    I tried it using presentation variable, and writing sql query, where is says " WHERE promo_id= @{variable}"
    but it is still not working.
    Please let me know the workaround for this issue.
    Thank you.
    - Vinay

    How is the End Date determined for your BETWEEN operator? I would assume that is variable. Also, is the second report on another dashboard page or on the same page? Assuming both reports are on the same page, do the below. If not, you can use the same prompts on the second dashboard page. Set the scope to "dashboard" and the selection the user makes carries to the second page.
    The easiest way is to have 3 Dashboard prompts: Promo_ID, Start_Dt, and End_Date. Set these prompts to PVs: pvPromoID, pvStartDate, and pvEndDate, respectively.
    Filter report one on pvPromoID and pvStartDate.
    Filter the second report on pvPromoID and use pvStartDate in the filter of the Date column of report two. Assuming the BETWEEN values are variable, then you can write the following on the Date column of your second report:
    "Table Name"."Date ColumnName" <= '@{pvStartDate}' AND Table name"."Date Column Name" <='{EndDate}'
    And on your Promo column, use the filter "Table Name".Promo = '@{pvPromoID}'
    When the user selects the Promo ID, Start Date and End Date from the prompts, both the first and second reports will be filtered accordingly.

  • How to compare, current value in :block.text_item with the database value

    Hi
    Could you please tell me
    How to compare the current value in :block.text_item with the corresponding database column value.
    I am using forms 10g
    There is block and there is an text Item in that block.
    When I run the form and query the block (tabular), the :block.text_item shows me, whatever value there in the database.
    Now I add some value in the :block.text_item to the existing value.
    now
    the :block.text_item contains old+ new added value
    whereas
    the database table contains 'old' value
    Now on a button click , I want to find out what is the value that I have added
    Could you please tell me, is it possible without writing a select query?

    Hello,
    Now on a button click , I want to find out what is the value that I have addedSo you mean always user will add value in the existing value. Because this way will fail in one case. Let say
    Value in Database is = ABCD
    User opened the form and he removed the D and write E and now value is ABCE and length is still same 4. So, there is no addition.
    Anyway you can know the database value at runtime there is one property for item called DATABASE_VALUE. It gives the value which is in database while you are running the form before save. and you can use like this..
    Trigger = WHEN-MOUSE-DOUBLE-CLICK on item level
    DECLARE
      vItemValue DATATYPE; -- Set the data type according to your desired field.
      vValueAdded DATATYPE; -- Set the data type according to your desired field.
    BEGIN
      vItemValue:=GET_ITEM_PROPERTY('ITEM_NAME',DATABASE_VALUE);  -- It will return you the database value in vItemValue variable.
      IF LENGTH(vItemValue)>LENGTH(:FORM_ITEM_NAME) THEN  -- It mean something change or added
        vValueAdded:=SUBSTR(:FORM_ITEM_NAME,LENGTH(vItemValue)+1);
        MESSAGE('Added value is : '||vValueAdded);  -- It will show you the added value.
      END IF;
      -- now suppose you want to show the old and new value in message not the added one
      -- Then no need of IF condition. You can just use message like this
      -- And i would prefer to use like this way
      MESSAGE('Old Value : '||vItemValue||'  New Value - '||:FORM_ITEM_NAME);
      MESSAGE('Old Value : '||vItemValue||'  New Value - '||:FORM_ITEM_NAME);
    END;Hope it is clear.
    -Ammad

  • To fetch the srtfd value from PCL2 based on Pernr

    Hi,
    is there any function module to fetch field (srtfd ) value from PCL2 based on the pernr. My selection screen is having only pernr as the input and now have to get the srtfd value from PCL2.
    Kindly suggest me if any FM or best procees existed.
    Thanks,
    Murthy.

    Please somebody reply.

  • Parameters - Not Filling in when using Append all database values

    Hello, I am using CR 2013 and trying to create a parameter which would be a list of organization names from a MySQL Database.  I am able to see the tables and field names no problem but when I click Append all database values I get the circle and nothing appears.   It should be noted I can see a list of values in the "Select Expert" for that same table and field.
    I am running a Windows 7 machine.
    Please let me know if you have any suggestions or solutions.
    Thanks,
    Peter LaMont

    are you using win 7 sp1 or higher as per the supported platforms. you probably are but have to ask.
    i would recommend trying to create a new report off of the same db and try to use a dcp again. if that doesn't work, can you create a dcp (using a new report) off of a different database type...e.g. ms access?
    is anyone else in your environment having the same issue?
    if none of the above work it's most likely an install issue and you may wish to try an update of cr finding the latest sp here..

  • How to default value on bet01 based on ansal

    Dear Freinds
                i would like to know how to default the value for bet01 based on the
    calculated on ansal
    i want is
    q0008-bet01 = p0008-ansal /100.
    Can i default the value using the user exit ZXPADU01 or ZXPADU02. . As my ueser exit is not triggering  without me entering to bet01 .
    how can i do defaulting the value on bet01 ,
    regards
    shanti

    Dear  Chritisn
                 in my code i have done same thing what you have said as follows
    i have written the coding in ZXPADU02 as below
    data : wa_p0008 like p0008,
            i0008 like p0008,
           l_v_ANSAL type ANSAL_15,
           l_v_amount type PAD_AMT7S.
    CASE innnn-infty.
    when '0008'.
    MOVE-CORRESPONDING  innnn to wa_p0008.
    if wa_p0008-lga01 = 'MFPY'.
    l_v_ansal =  wa_p0008-ansal.
    l_v_amount = l_v_ansal / 100.
    if l_v_amount ne wa_p0008-bet01.
    move l_v_amount to wa_p0008-bet01.
    MOVE-CORRESPONDING wa_p0008  to innnn.------ at this point
    endif.
    when others.
    endcase.
    I have used move corresponding because i am getting the error as the strucutr eof INNNN to that WA_P0008 is different (unicode compatability error) ...
    now i can see the data in wa_p0008 and when i have move into innnn ..... i can see all the data in debuggin except  the bet01 value as below
    in wa_p0008 the data in debugin is as follows
    PERNR     N     8      00000004
    INFTY     C     4      0008
    SUBTY     C     4      0
    OBJPS     C     2                                                                               
    SPRPS     C     1                                                                               
    ENDDA     D     8      99991231
    BEGDA     D     8      20070716
    SEQNR     N     3      000
    AEDTM     D     8      00000000
    UNAME     C     12                                                                               
    HISTO     C     1                                                                               
    ITXEX     C     1                                                                               
    REFEX     C     1                                                                               
    ORDEX     C     1                                                                               
    ITBLD     C     2
    PREAS     C     2                                                                               
    FLAG1     C     1                                                                               
    FLAG2     C     1                                                                               
    FLAG3     C     1                                                                               
    FLAG4     C     1                                                                               
    RESE1     C     2                                                                               
    RESE2     C     2                                                                               
    GRPVL     C     4                                                                               
    TRFAR     C     2      01
    TRFGB     C     2      01
    TRFGR     C     8      E1
    TRFST     C     2      08
    STVOR     D     8      00000000
    ORZST     C     2                                                                               
    PARTN     C     2                                                                                WAERS     C     5      HKD
    VGLTA     C     2                                                                               
    VGLGB     C     2                                                                               
    VGLGR     C     8                                                                               
    VGLST     C     2                                                                               
    VGLSV     D     8      00000000
    BSGRD     P     3      100.00
    DIVGV     P     3      165.00
    ANSAL     P     8           1000.00  -
    value  entered on the screen
    FALGK     C     10                                                                               
    FALGR     C     6                                                                               
    LGA01     C     4      MFPY
    BET01     P     7              10.00  ---after calculation the value(1000/10)
    ANZ01     P     4          0.00
    EIN01     C     3                                                                               
    innn structure in debuggin  as follows:
    PERNR     N     8      00000004
    INFTY     C     4      0008
    SUBTY     C     4      0
    OBJPS     C     2                                                                               
    SPRPS     C     1                                                                               
    ENDDA     D     8      99991231
    BEGDA     D     8      20070716
    SEQNR     N     3      000
    AEDTM     D     8      00000000
    UNAME     C     12                                                                               
    HISTO     C     1                                                                               
    ITXEX     C     1                                                                               
    REFEX     C     1                                                                               
    ORDEX     C     1
    PREAS     C     2                                                                               
    FLAG1     C     1                                                                               
    FLAG2     C     1                                                                               
    FLAG3     C     1                                                                               
    FLAG4     C     1                                                                               
    RESE1     C     2                                                                               
    RESE2     C     2                                                                               
    GRPVL     C     4                                                                               
    DATA1     C     250     0101E1      0800000000    HKD                00000000#&#5644;&#3152;###&#3072;                MFPY######        ######        ######        ######
    DATA2     C     250
    we can see in the debuggin for the DATA1 it is having the MFPY value  but i dont find the value for bet01 ..........
    and iam not getting the value on the screen in PA30 for the bet01.
    please let me know what i have to do , and let me know where i went  wrong.
    regards
    shanti

  • How to make default value for region based on city?

    Dear Experts,
    When city is selected in TRIP or PR05, how to make the default value of city based on region?
    The standard search help givenfot citydoesnt contain any enhancement point?
    Pls suggest how to resolve this!!!
    Thanks In Advance
    Rgrds,
    Sravan

    Hello Sahil
    Account and CC/PC are 2 different entity types. For PC and CC there is dependency. First you have to load Cost centers and then load PC.
    For CC - load CC master data first. Then load hierarchy file then group file and finally assignment file.
    Follow same process for PC.
    GL you can load independently but you have first load group GL then operational GL and then GL at company code level,
    Kiran

  • Populating Database values into a combo box in STRUTS Framework

    Hi Guys,
    I am currently working on a STRUTS Framework project and I can't get much resources related to the problems that I'm facing.
    Currently I need to populate a JSP file's Combo box with database values. What I don't know here is the syntax used to in STRUTS framework to populate the Combo box with database values. Anyone with experience related to this topic, please kindly help me out.

    Struts doesn't define anything about the datab layer. You're free to implement how you will.
    Struts instead guides you into following an MVC pattern.
    You populate a combo box with values from a bean.
    So you need to set up a bean for this page to talk to.
    That bean can be populated from the database - but at that point you're in java/jdbc code - and away from the struts layer.
    My suggestions
    1 - Define a bean to represent the information from the database.
    2 - write a method that queries the database, and copies the data into a List of those beans. This will be your Data access layer.
    3 - in your action, call that method, and then set the list of beans as a request attribute. Or maybe as a property on a form.
    4 - use that list of beans to populate your dropdown box.

Maybe you are looking for

  • How to initialized main method in a deployed application

    Hello, I am trying to deploy a simple java application to OC4J, I created a jar file as my deployment profile and then I created EAR file and finally delpoyed succesfully, but I'm wondering how can I start my main method in deployed application, note

  • Web content editor

    Could someone recommend a good and free web content editor? Best regards, Gabriel.

  • Java 1.4.2 & Jinitiator

    Please Help We are about to upgrade our major financial system to a web based product using JRE 1.4.2_05, however some of our other applications use jinitiator, either 1.3.1.13 or 1.3.1.18. These products will not run alongside each other for obvious

  • I´ve made four Columns with text and an Image over the middle of two columns. How do I put a text u

    I´ve made four Columns with text and an Image over the middle of two columns. How do I put a text under the Image that spans over the Columns?

  • Row Height on HFM Form

    Hi This is a basic question. Is it possible to change the row height of one particular row on the web form ? I have a form with form row height as 20px. There is a BLANK row with custom header 'Check' that needs to be of height '5px' Is there a way t