How To Insert A New Record to MS Access table database in GUI

How To Insert A New Record to MS Access table database in GUI

Hello, I've been working on the actionPerformed part of my java application that involves inserting a record into a 6-column table in my MS Access database table. I'm doing fine with retrieving the data with ResultSet, but I'm stuck on the actionPerformed events. The problem I'm having is that when the user clicks on the Add button, it's not doing anything (not even my JOptionPane). I'm stuck at this step. For simplicity, I am including only the add button listener and action events. I know I'm missing something, I just couldn't figure out where. Thanks in advance for your help. Below is part of my java code.

private class AddButtonListener implements ActionListener { public void actionPerformed (ActionEvent d) {

int donorNum = recordNum;

String name;
    name = firstNameTextField.getText();
String lastName;
    lastName = lastNameTextField.getText();
String middleI;
    middleI = mITextField.getText();
String charity;
    charity = comboBox.getSelectedItem().toString();

String pledge = pAmountTextField.getText();    
double pl;
     pl = Double.parseDouble(pledge);

record.setRecordNumber(donorNum);
record.setFirstName(name);
record.setLastName(lastName);
record.setMiddleInitial(middleI);
record.setCharity(charity);
record.setPledge(pl);

recNum.add(record.getRecordNumber());
lName.add(record.getLastName());
fName.add(record.getFirstName());
midI.add(record.getMiddleInitial());
lCharity.add(record.getCharity());
donAmount.add(record.getTotalPledge());

recordNum++;      


try {
    rs.moveToInsertRow();
    rs.updateInt(1, recordNum);
    rs.updateString(2, " " +name);
    rs.updateString(3, " " + lastName);
    rs.updateString(4, " " + middleI);
    rs.updateString(5, " " + pledge);
    rs.updateString(6, " " + charity);


    rs.insertRow();
    rs.moveToCurrentRow();
    st.close();
    rs.close();

    st = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);        
    String sql = "select * from DonorTable";
    rs = st.executeQuery(sql);

    rs.next();

    firstNameTextField.setText(rs.getString("First_Name"));
    lastNameTextField.setText(rs.getString("Last_Name"));
    mITextField.setText(rs.getString("Middle_Initial"));
    pAmountTextField.setText(rs.getString("Pledge_Amount"));
    comboBox.setSelectedItem(rs.getString("Charity_Name"));




 JOptionPane.showConfirmDialog(null, "Donor " + "  " + name + "  " + lastName + "  " + middleI + " added");

}
catch (Exception ad) { 
}


}

}

View Answers









Related Tutorials/Questions & Answers:
How To Insert A New Record to MS Access table database in GUI
How To Insert A New Record to MS Access table database in GUI  Hello, I've been working on the actionPerformed part of my java application that involves inserting a record into a 6-column table in my MS Access database table. I'm
How to insert or delete records in MS access database using jsp - JSP-Servlet
How to insert or delete records in MS access database using jsp  Hi friends please provide me a solution that i insert or delete record from a database using java server pages. I used the microsoft access 2003 database. PlZ
Advertisements
how to insert values from jsp into ms access
how to insert values from jsp into ms access   how to insert values using jsp into ms access database
applet connected to table in MS Access database
applet connected to table in MS Access database   i have connected my java code with the MS access database and this is my code, can anyone tell me how to show the table in an applet...pls import java.sql.
how to access the MS ACCESS database with java - Java Beginners
how to access the MS ACCESS database with java  how can we insert,delete,update,search records of ms access with java
how to access the MS ACCESS database with java
how to access the MS ACCESS database with java   how to access the MS ACCESS database with java how can we insert,delete,update,search records of ms access with java   Java MS Access database connectivity Follow
cannot insert data into ms access database - Java Server Faces Questions
cannot insert data into ms access database   go back   Hi Friend, You can use the following steps for creating DSN... Microsoft Access Driver(*.mdb) 5. Select database name and Create the DSN name
Accessing Ms access data in JAVA GUI Envi.
Accessing Ms access data in JAVA GUI Envi.  Q.How to insert data into ms access data in java using swing ? Q.How to slove (access denided ("java.lang.RuntimePermission" "accessClassInPackage.sun.jdbc.odbc")" these exception
link hibernate to MS ACCESS database
link hibernate to MS ACCESS database  how to link hibernate to ms access database instead of sql database
how to connect to MS access database in JSP?
how to connect to MS access database in JSP?  how to connect to MS access database in JSP? Any seetings/drivers need to be set or installed before it? Please tell what needs to be done after creating a table with an example
How To Connect MS ACCESS 2003 Database in C Program with Graphics.
How To Connect MS ACCESS 2003 Database in C Program with Graphics.  How To Connect MS ACCESS 2003 Database in C Program with Graphics
Write a query to insert a record into a table
Write a query to insert a record into a table  Write a query to insert a record into a table   Hi, The query string is as follows-ADS_TO_REPLACE_1 Insert into employee values ('35','gyan','singh'); Thanks
How to Open Picture From M.S. Access Database using Java Servlet ?
How to Open Picture From M.S. Access Database using Java Servlet ?  Hi all my Friends I have below code which insert a picture into M.S. Access Database But i m still not able to open this picture through Java using M.S. Access
How To Display MS Access Table into Swing JTable - Java Beginners
How To Display MS Access Table into Swing JTable  How to Display Records From MS Access Database To JTable. Plz Help Me  Hi Friend...){ System.out.println(e); } JTable table = new JTable(data, columnNames); TableColumn
How to store JComboBox selected Item into Ms Access Database - Java Beginners
How to store JComboBox selected Item into Ms Access Database  How to store JComboBox selected Item into Ms Access Database.  Hi Friend...=new JComboBox(); JButton b=new JButton("Insert"); try{ Class.forName
How to search the table name in MS SQL Database 2005 from application
How to search the table name in MS SQL Database 2005 from application  How to search the table name in MS SQL Database 2005 from application from our helpdesk application? application might be in html
How to Access MS Access in jar.
How to Access MS Access in jar.  how do i access my Ms-Access file... to access it via Code or is their any alter-native?? Do i need any Driver to do this ... i m able to access a Ms-access via JDBC but cant find the file wen
how to store image file and videofile in ms access database using java? - JDBC
how to store image file and videofile in ms access database using java?  how to store image file and video file in ms access database using java
how to delete specified coloumn from database(MS Access) by using windows application
how to delete specified coloumn from database(MS Access) by using windows application  how to delete specified coloumn from database(MS Access) by using c# windows application
Updating Ms Access Database using jsp - JSP-Servlet
Updating Ms Access Database using jsp  Hi I am new to jsp and I am trying to update a record in an access database. I only want to update part of the record because the other columns already have data. When I use Update
code for insert the value from jsp to access database
code for insert the value from jsp to access database  code for insert the value from jsp to access database
How to use JTable with MS-Access
How to use JTable with MS-Access   I have Three Column in Database (MS-Access). 1. Name 2. City 3. Contact I want to Display....   Here is an example that retrieves the data from MS Access database
How to use JTable with MS-Access
How to use JTable with MS-Access   I have Three Column in Database (MS-Access). 1. Name 2. City 3. Contact I want to Display....   Here is an example that retrieves the data from MS Access database
retrive record from the text field and insert into to database
retrive record from the text field and insert into to database  the following code is inserting values in the my sql database but i want to insert... =new ArrayList(); String query = "insert into LTCINFO.PERSONS set
How to Validate JRadioButton and How to Save data from JRadioButton to MS Access Database - Java Beginners
JRadioButton I want Store Information from JRadioButton to MS Access Database, and I...How to Validate JRadioButton and How to Save data from JRadioButton to MS...:access"); PreparedStatement st=con.prepareStatement("insert into names(name,age
How To Display both image and data into Swing JTable which is retrieved from ms access database
How To Display both image and data into Swing JTable which is retrieved from ms access database  So far this is my code how can i display both image and data from database.. while (rs.next()) { Vector row = new Vector(columns
how to insert one table to anothere table
how to insert one table to anothere table  i have insert the record one table then i retrve the value of that table i insert one value at a time
to get picture from ms access database by jsp-servlet....
to get picture from ms access database by jsp-servlet....  I have inserted a picture in ms access data base,,,how we can retrieve that picture by using jsp
How to retrieve record from table
How to retrieve record from table  Hi. I have a field in database...,kanchipuram for a single record. I have to retrieve these data from the field table.... how to do
how to retreive values from MS Access Database based on the values entered in textbox values in jsp file
how to retreive values from MS Access Database based on the values entered in textbox values in jsp file  Hi am new to java. i need to create... in MS Access Database. the table structure is Sno JobName ProgramName Problem
Insert Serialized Object into Database Table
Insert Serialized Object into Database Table In the previous tutorial, you... it into a file. In this section, you will learn how to Insert a serialized object into database table, deserialize it after fetching it from database table
JDBC Video Tutorial- How to insert data into MySQL database table?
Tutorial: How to insert data into MySQL Table? Here is the code of the full Java...','10000')” to insert the database into database... of creating the database table: CREATE TABLE `employee` (   
ms access
ms access  how to delete the autonumber from ms access using java delete code
MS-Access
MS-Access  I am trying to upload a image to ms-acess using jsp,and my...: [Microsoft][ODBC Microsoft Access Driver]COUNT field incorrect ".I think i set wrong datatype for table column in which my image going to be saved.I set
insert user session into other oracle database table
insert user session into other oracle database table   hello i am... comments then how i can retrive his user id using session and store id into comments table. with user id i also want to insert date and current time in to database
MS Access` - JDBC
to insert image into MS Access Database. Now the task is how to retrieve the image from database. And i am developing a JFrame to retrieve tha fields from database...MS Access`  Hello Sir, Thank you very much for your valuable
HTML(Registration form) to Jsp to stored into MS ACCESS database
HTML(Registration form) to Jsp to stored into MS ACCESS database  i am sending one html file that contain 18 fields these are stored in ms-access database by using jsp code.i want to urgent jsp code. please urgent sir. thank
JComboBox Insert Edited Value Into Table
through command prompt. To insert a value into the table we will use MS-Access... how to make JComboBox an editable and then how to insert the new edited value.... In this example we will first create a database table (How To Create Table
Jdbc MS-Access question
Jdbc MS-Access question  How to delete records from the three table in MS-Access? They are in relationship with each other regarding to data field
Jdbc MS-Access question
Jdbc MS-Access question  How to delete records from the three table in MS-Access? They are in relationship with each other regarding to data field
Ms Access
Ms Access   How to get query for Primary key from MsAccess?   SELECT column_name FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE WHERE table_name..._USAGE WHERE table_name = 'data'; In the above query, data is our table name
MS ACCESS
MS ACCESS  i have done : Insert form data into MS database..., *.accdb)};DBQ=C:\\myca\\demo\\authors.accdb"); // Creating a database table... data displayed in table in my database (authors.accdb) when i run my
MS ACCESS
MS ACCESS  i have done : Insert form data into MS database..., *.accdb)};DBQ=C:\\myca\\demo\\authors.accdb"); // Creating a database table... data displayed in table in my database (authors.accdb) when i run my
MS ACCESS
MS ACCESS  i have done : Insert form data into MS database Follow...)};DBQ=C:\\myca\\demo\\authors.accdb"); // Creating a database table... data displayed in table in my database (authors.accdb) when i run my
display data from a table in Access Database in a HTML page
display data from a table in Access Database in a HTML page  how to display data from a table in Access Database in a HTML page in a Java Program
Insert Records in Table
Insert Records in Table       The Insert data in Table is used to insert  records or rows into the table in database. The Syntax used to insert records into a table
MS access
MS access  how do i access my Ms-Access file placed in the same jar file where my application code/class file r present??? Want to access it via Code. Can anyone help me ? Please give reply urgent...   give me reply
How to insert data into MySQL Table?
How to insert data into MySQL Table?  Hi, How to insert the data into MySQL Database? Please explain me with the examples and videos thanks. Thanks   Hi, The insert into query is used to insert the data into MySQL
ms access
and password" from my ms access............and detail in register(table in my ms... "username and password" from my ms access............and detail in register(table in my... has to login . i already created ms access page and inserted values throught
ms access
and password" from my ms access............and detail in register(table in my ms... "username and password" from my ms access............and detail in register(table in my... has to login . i already created ms access page and inserted values throught

Ads