Hi, Can anyone help me. I am trying to insert, update and delete a record from an Access database using swing. The GUI has been created and the connection to the database established. After entering the record on the screen and pressing the save button, I am unable to insert. Also my combo box doesn't retrieve records into the appropriate fields on the screen. In-fact it doesn't retrieve the records from the database at all. sample codes to help me will be highly appreciated.
I know I am doing a few things wrong because I am new to Java but I am learning quickly.
I am sorry, I do not understand how the thread works. I have attached a zip file with these threads I am sending but I can't seem to find it on the screen after it had been sent. I don't know what I am doing wrong. The code is quite long hence I cannot paste it in the thread. Can I send it to your e-mail address? If yes, please send me your e-mail address.
this is how you attache file
1, click on the "post reply" button
2. then scroll down and look towards the left of the page you will find
a button with caption "browse" and right underneath there are formata
allowed to be uploaded(e.g gif,zip etc)
thats it when you submit reply then it should be uploaded...
every users email adress can be found from that users profile...
values in bold will be entered as litterals and will not be used as variables
stmt.executeUpdate("INSERT INTO Books_in_stock " + " VALUES ('" + txtcopies + "', '" + txttitle + "', '" + txtauthor + "', 'txtpub', 'txtisbn', 'txtyear', 'txtcategory', 'txtprice')");
if you want them to be entered as variables then you will need to use proper string cancatenation format for variables
I delibrately left the values in bold without the double qoutation marks as I was testing which values are stored. The first couple of variables (i.e. txtcopies, txttitle, txtauthor) are left blank in the database while the ones in bold are inserted as string literals i.e. txtpub, txtisbn, txtyear e.t.c.
I believe for some reasons, the values entered on the screen are not been retrieved by the getText method. The JTextFields have been declared i.e. copies, author, year, isbn e.t.c and as you can see from the code I sent to you, I have also used the getText method to retrieve these values. The records are been inserted but as string literals. The ones passed in as variables are left blank in the database.
As I said before I need to the full code to see in action,however from what you said could it not mean that your variables are empty? that is they do not have any values in them?(you can email me the whole project in a zip file....
I'll find some time in next few days the run your project...