Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. displaying a data in textbox

displaying a data in textbox

Scheduled Pinned Locked Moved Database
questiondatabasehelp
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Rharzkie
    wrote on last edited by
    #1

    Its me again, i making a grade data entry. I have a database of diffenrent subjects. The fields that i will going to use is these: Subject code, Subject description, and professor. What I want is to view the subject description and the professor in the textboxes when I select a subject code in the combo box. I had already made an OleDbDataAdapter for that, and the subject codes was the data member in the combobox. The subject codes is already the item of the combobox but my problem is, the subject description and professor was not appeared in the textbox. What I want is this to view to its corresponding textboxes. I used this code: For ctr = 0 To DataSet31.studentsubjects.Rows.Count - 1 dr = DataSet31.studentsubjects.Rows(ctr) If ComboBox1.SelectedItem = dr("subject") Then subjdesc.Text = dr("subjdesc") prof.Text = dr("professor") End If Next Is the code above correct??? If its not, what is the right code???? Where will I going to put the codes???

    C 1 Reply Last reply
    0
    • R Rharzkie

      Its me again, i making a grade data entry. I have a database of diffenrent subjects. The fields that i will going to use is these: Subject code, Subject description, and professor. What I want is to view the subject description and the professor in the textboxes when I select a subject code in the combo box. I had already made an OleDbDataAdapter for that, and the subject codes was the data member in the combobox. The subject codes is already the item of the combobox but my problem is, the subject description and professor was not appeared in the textbox. What I want is this to view to its corresponding textboxes. I used this code: For ctr = 0 To DataSet31.studentsubjects.Rows.Count - 1 dr = DataSet31.studentsubjects.Rows(ctr) If ComboBox1.SelectedItem = dr("subject") Then subjdesc.Text = dr("subjdesc") prof.Text = dr("professor") End If Next Is the code above correct??? If its not, what is the right code???? Where will I going to put the codes???

      C Offline
      C Offline
      Colin Angus Mackay
      wrote on last edited by
      #2

      Rharzkie wrote:

      ComboBox1

      Can you please name your variables with good names rather than accept the defaults that Visual Studio gives you.

      Rharzkie wrote:

      ComboBox1.SelectedItem = dr("subject")

      What does ComboBox1.SelectedItem return? Put a break point down and see what value it is returning. Also it will aid the debugging process if you assign the result of method and property calls to something then test on the local variables - it will make it easier to see what is going on in the debugger.


      Upcoming events: * Glasgow: Mock Objects, SQL Server CLR Integration, Reporting Services, db4o, Dependency Injection with Spring ... "I wouldn't say boo to a goose. I'm not a coward, I just realise that it would be largely pointless." Ready to Give up - Your help will be much appreciated. My website

      R 1 Reply Last reply
      0
      • C Colin Angus Mackay

        Rharzkie wrote:

        ComboBox1

        Can you please name your variables with good names rather than accept the defaults that Visual Studio gives you.

        Rharzkie wrote:

        ComboBox1.SelectedItem = dr("subject")

        What does ComboBox1.SelectedItem return? Put a break point down and see what value it is returning. Also it will aid the debugging process if you assign the result of method and property calls to something then test on the local variables - it will make it easier to see what is going on in the debugger.


        Upcoming events: * Glasgow: Mock Objects, SQL Server CLR Integration, Reporting Services, db4o, Dependency Injection with Spring ... "I wouldn't say boo to a goose. I'm not a coward, I just realise that it would be largely pointless." Ready to Give up - Your help will be much appreciated. My website

        R Offline
        R Offline
        Rharzkie
        wrote on last edited by
        #3

        The ComboBox1 is for the list of the subject code. I use the DISTINCT in query builder to display the items in the combobox. I use the OleDbDataAdapter1 for that. But the connection that i will going to display in textbox is OleDbDataAdapter3. In short, i use different connection from the combobox and the textboxes. Is this correct?

        C 1 Reply Last reply
        0
        • R Rharzkie

          The ComboBox1 is for the list of the subject code. I use the DISTINCT in query builder to display the items in the combobox. I use the OleDbDataAdapter1 for that. But the connection that i will going to display in textbox is OleDbDataAdapter3. In short, i use different connection from the combobox and the textboxes. Is this correct?

          C Offline
          C Offline
          Colin Angus Mackay
          wrote on last edited by
          #4

          Rharzkie wrote:

          The ComboBox1 is for the list of the subject code.

          Yes, but ComboBox1 still isn't a good name for it, is it?

          Rharzkie wrote:

          OleDbDataAdapter1

          Rharzkie wrote:

          OleDbDataAdapter3

          :omg: How do you keep track of what each of these does?

          Rharzkie wrote:

          Is this correct?

          I have no idea. This code is obviously a mess. My suggestion is to start by naming things properly. Then it might be an idea to create a DAL and remove all your database interaction out of the user interface classes. It might also be an idea to do what I asked in my previous post and answer the question I asked. ("What does ComboBox1.SelectedItem return?" - And I want actual values and object types, not what you think it should return)


          Upcoming events: * Glasgow: Mock Objects, SQL Server CLR Integration, Reporting Services, db4o, Dependency Injection with Spring ... "I wouldn't say boo to a goose. I'm not a coward, I just realise that it would be largely pointless." Ready to Give up - Your help will be much appreciated. My website

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups