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

Have Programming Question? Ask it here!
 
 
 


Mike Lee
How To Insert A New Record to MS Access table database in GUI
0 Answer(s)      a year and 10 months 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 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 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
Advertisements
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
Using C# DataGridView to insert record into Microsoft SQL Server 2005 database - SQL
Using C# DataGridView to insert record into Microsoft SQL Server 2005 database  Dear Sir, I am new to Microsoft SQL Server 2005. Currently, i'm... encounter a problem of using C# DataGridView to insert record into Microsoft
MS Access` - IDE Questions
MS Access`  hello sir, how to configure MS Access database in Net Beans5.5... and i have a doubt, where should we run the below code...either in IDE or in any editor like EDITPLUS. waitin for your reply.... thank you
MS Access - JSP-Servlet
MS Access  hello sir, i want to use MS.Access as my database..so my problem is how to connect MS Acces database with servlets ... thank you... stepts 1.to configure the ms access database to your system control panel
MS Access - WebSevices
" which have access database and for images we have created a field in the table...MS Access  hello sir, i am trying to write a code which should take images from a particular folder and data from MSAccess..please help me..thank
MS Access - JDBC
information about MS access database...but still i am having doubt in that topic. My problem is : Is there any jar to connect MS Access and java ... because... to be remember 1.to configure the ms access database to your system control
how to insert the physical path of an image in database - JDBC
how to insert the physical path of an image in database  hello I m... it physical path will get saved in a database.. I have table created , the image column is of varchar datatype.. plz can you tell me how to insert image's
MS ACCESS - JDBC
MS ACCESS  java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression 'origin='src' destination='dest''. THAT MY PROBLEM
Dialect for MS Access - Hibernate
Dialect for MS Access  Can someone tell the Dialect for MSAccess.I need it urgently Thanks in advance
MS-ACCESS Query Problem - SQL
MS-ACCESS Query Problem  hi sir i have table which is initially... records so these all records i want to insert into Deleted Table plz can u give Query... Sex Hostel so another table is Student Attributes: Roll Name Add
jdbc warning regarding to ms access
jdbc warning regarding to ms access  shows warning msg while compiling using ms access : warning: sun.jdbc.odbc.JdbcOdbcDriver is Sun proprietary API... { DriverManager.registerDriver(new sun.jdbc.odbc.JdbcOdbcDriver()); Connection con
Deleting Blob Data from Database table using servlet
Deleting Blob Data from Database table using servlet In this section, we will discuss about how to insert a blob data into a database table. A Blob stores a binary large object in the database table's row. Blob object
audio files in jdbc connectivity with ms-access - JDBC
audio files in jdbc connectivity with ms-access  i need to know how to retrieve audio files through jdbc connectivity with ms-access and how to play... static void main(String[] args) { try{ String url="jdbc:odbc:access"; File
java to MS Access conectivity - Swing AWT
java to MS Access conectivity  give me source code to stored... database on the ACCESS.  Hi Friend, Follow these steps: 1. Open...); ADD=new JButton("Insert"); ADD.addActionListener(new ActionListener
how to insert list box in java script dynamically and elements retrieving from database like oracle
insert new course in a table.. It should be seen in my list box...how to insert list box in java script dynamically and elements retrieving from database like oracle  Hi, how to dynamically increase size of list
How to save JCombobox Selected Item in to Access Database - Java Beginners
How to save JCombobox Selected Item in to Access Database  How to save JCombobox Selected Item in to Access Database  Hi Friend, Try... JComboBox(); JButton b=new JButton("Insert"); try{ Class.forName
How to Store Float Value into Access Database - Java Beginners
How to Store Float Value into Access Database  Hello sir,I want to Store Student Marks Percentage into Access Database in Float Value how i can Store.... To store the double value in Access database, you need to set the datatype
Insert text into database table using JSP & jQuery
Insert text into database table using JSP & jQuery In this tutorial , the text is inserted into database table using JSP & jQuery. In the below... for connectivity and fetching data from database table. insert.jsp <%@ page language
Insert Mysql Blob data
how to insert a blob data into a database table. A Blob stores a binary large object in the database table's row. Blob object contains a logical pointer... of the database table. Blob object  is valid for the duration of the transaction
java gui database - Java Beginners
java gui database  I have eight files. Each file has exactly same... record. It means there are 100 records(each of eight items). I can display the data on command line but I do not know how to display the same using java
insert and delete data in database
insert and delete data in database  insert and delete data in database from servlets through JDBC   Hi Friend, Please visit the following links: Insert Data Delete Data Thanks
Insert Blob(Image) in Mysql table using JSP
Insert Blob(Image) in Mysql table using JSP In this Section, we will insert blob data(image) in Mysql database table using JSP code. A Blob stores a binary large object in the database table's row. Blob object contains a logical
how to insert list box in java script dynamically and elements retrieving from database like oracle
how to insert list box in java script dynamically and elements retrieving from database like oracle  hi all, how can i insert elements into java script list box retrieving from Database. whenever I insert any element in the Db
connecting to access database
Access Driver(*.mdb) Select database name and Create the DSN name (e.g access...connecting to access database  print("code sample");Hi I Write java... this there is no error but my data is not going to my Acess Database. There is working
Check Whether Record is already Exists or Not with Database Connectivity - Java Beginners
Check Whether Record is already Exists or Not with Database Connectivity ...(Exception e) {} } } For the above code, we have used database table... in the database with Swing Application ,if It is Already Exists then I want To Show MsgBox
Insert a row in 'Mysql' table using JSP Code
Insert a row in 'Mysql' table using JSP Code In this section, we will discuss about how to insert data in Mysql database using JSP code. Query...; Mysql database Table. Code to insert row in Mysql table : databaseinsertion.jsp
updating a table in a database - SQL
updating a table in a database  give me complete source code in java to execute the sqlquery such that (update table_name set phone no=? where cous_id=?). or in simple way give me source code to update my table in MsAccess
To insert maximum number of data in database.
To insert maximum number of data in database.  how to change string data type into clob data type in jsp   Hi Friend, Please visit the following link: http://www.roseindia.net/jdbc/insert-clob-example.shtml Thanks
Java to insert picture to database - JSP-Servlet
Java to insert picture to database  Hi Guys, Please assist me on this. Below is the code I wanted to use to insert picture into Ms Sql server 2000 but after the insertion, I got this in the database (back-end
Applet database access - Applet
Applet database access  HI... I'm having an applet where we should display the database values in the applet... It works fine in the local system... no change... How to implement this...?? thanks in advance
Problem with Double type Value in Access Database - Java Beginners
Problem with Double type Value in Access Database  Hello sir I have store Double Type Value in MS Access Databse,but when I search Record... Mobile Number with MS access Database,plz Help Me Sir.   Hi Friend
how to close the connection object,statement object,resultssetobject when using the microsoft access a database - SQL
how to close the connection object,statement object,resultssetobject when using the microsoft access a database   Hi Friend, I am developing the webapplication using the jsp(business logice-jsp).backend is microsoft access
Insert into table using Java Swing
INSERTION IN TABLE USING SWING In this section, We will insert rows into "Mysql" database using "Swing". What is Swing? Swing is the extension to the Awt library, includes new and improved components
how i conditional access the data from database using combo box. - JSP-Servlet
how i conditional access the data from database using combo box.   i... appears named Subject values Arts, Commerce, Science. how i conditional access the data from database when i select class 11 0r 12. Here is JSP file
Problem with JRadioButton and Access Database - Java Beginners
in Access Databse, I want to store course type in to database and also other fields...(p3,"Error in deleting record."); } } }); editbtn1.addActionListener(new...Problem with JRadioButton and Access Database  Hello sir ,Here I have
Load Coursenames from MS Acess Database to JComboBox - Java Beginners
Load Coursenames from MS Acess Database to JComboBox  Hello sir, I want to Load/add Course names which stored in Ms Acess 2007 Database, plz help... sf=new SwingFrame(); } public SwingFrame(){ JFrame f = new JFrame("Frame
In this section you will learn how to rename MySQL database.
How to rename MySQL database? In this section we will learn the safest method... version 5.1.7: RENAME {DATABASE | SCHEMA} db_name TO new_db_name... into new database Take the backup of database using mysqldump utility
Insert text file data into Database
Insert text file data into Database In this section, you will learn how to insert the text file data into the database. For this purpose, we have created... is then inserted into the database. Here is the student.txt: 1 
PHP Insert Value
Insertion of data into table: We will study in this tutorial how to insert...'); Now to insert values into table:   ii)    Using WAMP server, following screenshots will help you to learn how to insert into values
Creation and insertion in table
 = statement.executeUpdate(QueryString);     // sql query to insert values in the specified table...CREATION OF  TABLE,INSERTION &DISPLAY OF DATA  USING SQL QUERY   In this progam we create table in MYSQL using "create"
How to rename MySQL table?
How to rename MySQL table? The designing and development of any software... provide appropriate sql command to change the database name. The alter table <table name> rename <new table name> command can be used to rename
Insert excel file data into database Using Java Programming
Insert excel file data into database in Java Program In this PHP tutorial section, you will learn how to insert excel file data into the database. We have... is then used to store file values into the database. Here is the code of Insert
Displaying Database using PHP
now, we have done the creation part of database and table. In this tutorial, I will show you how to insert the information by using form on a website... is to assign the values of the form in the variable and insert into the database
iPhone Simple Table View
Simple Table View In this tutorial will learn how to use Table View and also how to add object to table view, to insert the object into the table view we have to take an array and through that will add or insert the object into the Table
JDBC, Java Database Connectivity
Server, MS Access etc. It gives necessary tools to make a connection... to the database developers uses JDBC API to perform insert, update, select... implementations for each database. For example to access oracle database we need the JDBC
Write records into text file from database
Write records into text file from database You have already learnt how to insert records from text file to database. But here we are going to retrieve records... created a table in the database. Then using the ResultSet, we have selected
Simple Table View With Next View
Simple Table View With Next View In this iphone tutorial will learn how to use Table View and also how to add object to table view, to insert the object into the table view we have to take an array and through that will add or insert
 

 

 

DMCA.com