I am trying to learn GUI and Database programming by creating a small application (or should I say attempting to create one).
I have a screen built and I have my database connection working. As a matter of fact, I was able to add a "Search" button that would search the database, but it was very "simple" and required you to enter the "id" field value. Therefore you were limited to searching on just one field.
What I am looking to do, is to allow the search to be a little more rebust. So, I am thinking that when a user hits the Search Button, I will clear all my text fields on the screen, allow the user to enter data into any of the fields on the screen and then hit execute.
This is where I am looking for some guidence. I know that I would like to check each field on the screen to see if there is anything in it or not, if so , add that value as one of the "where clauses" in the search query, on the same note, if there field is null, do not include that field in the query.
I know I can do this, but I was wondering if there is a more efficient way of doing this then when Execute is pressed and my Search flag is true, checking each field from the screen...
My thought is down the road when I have more then 2 or 3 screens, it would be nice to try and build this so any screen I add would have this functionality. (Which I know is what java is about, that is what I am trying to teach myself here....)
Also, thinking ahead of when an "Update" option is added. This will also have to check the previous value of a field to the current value. If it has changed, then place the new value in the set clause of the sql to update the database value.
Sorry if I am using the wrong terms here. I have been programming in java but it has alway been changing/modifying code of an application that already is out there. I have never built or tried to build something like this myself.
Quite frankly, I am still trying to get the objects theory through my head, coming from a NON-object oriented programming background
Thanks in advance.
PS
One other thing, if somebody knows of some good online tutorials or even a book that I could purchase, I would like to know.
I have googled this a million times and I keep getting results from NetBeans, which I DO NOT want to do. This thing is building all the code in the back ground, and that is the part that I am trying to learn.
Thanks
Chris
I have a screen built and I have my database connection working. As a matter of fact, I was able to add a "Search" button that would search the database, but it was very "simple" and required you to enter the "id" field value. Therefore you were limited to searching on just one field.
What I am looking to do, is to allow the search to be a little more rebust. So, I am thinking that when a user hits the Search Button, I will clear all my text fields on the screen, allow the user to enter data into any of the fields on the screen and then hit execute.
This is where I am looking for some guidence. I know that I would like to check each field on the screen to see if there is anything in it or not, if so , add that value as one of the "where clauses" in the search query, on the same note, if there field is null, do not include that field in the query.
I know I can do this, but I was wondering if there is a more efficient way of doing this then when Execute is pressed and my Search flag is true, checking each field from the screen...
My thought is down the road when I have more then 2 or 3 screens, it would be nice to try and build this so any screen I add would have this functionality. (Which I know is what java is about, that is what I am trying to teach myself here....)
Also, thinking ahead of when an "Update" option is added. This will also have to check the previous value of a field to the current value. If it has changed, then place the new value in the set clause of the sql to update the database value.
Sorry if I am using the wrong terms here. I have been programming in java but it has alway been changing/modifying code of an application that already is out there. I have never built or tried to build something like this myself.
Quite frankly, I am still trying to get the objects theory through my head, coming from a NON-object oriented programming background
Thanks in advance.
PS
One other thing, if somebody knows of some good online tutorials or even a book that I could purchase, I would like to know.
I have googled this a million times and I keep getting results from NetBeans, which I DO NOT want to do. This thing is building all the code in the back ground, and that is the part that I am trying to learn.
Thanks
Chris