displaying a data in textbox
-
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??? -
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???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
-
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
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?
-
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?
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