Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners How To Insert A New Record to MS Access table database in GUI
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Mike Lee
How To Insert A New Record to MS Access table database in GUI
0 Answer(s)      2 years ago
Posted in : Java Beginners


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) { 
}


}

}


Advertisement
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 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
Advertisements
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
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
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
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
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 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
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 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 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
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- Insert into employee values ('35','gyan','singh'); Thanks
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 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
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
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 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 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
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
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 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
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
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 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
 

 

 

DMCA.com