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



Home Answers Viewqa JDBC updation problem during transaction to ms-access
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


kamal nagpal
updation problem during transaction to ms-access
1 Answer(s)      2 years and 5 months ago
Posted in : JDBC


Hey friends I am a beginner to java,and my problem is related to updation query in ms-access.Actually have created a database and through a jform button I am retrieving data in text fields and then updation is made in these textboxes and then updation query is fired through a button .Now problem is at text fields are getting data from database but updation is not executed and exception is given that 'top few parameters in update query,but I have checked all parameters correctly.And I can't find solution of this problem.please help me.


Advertisement
View Answers

August 1, 2012 at 12:00 PM


Here is a code that updates the data. When the user enter any id and click the edit button, the record of that corresponding id, values will get displayed into the form. Then you can easily update that particular record.

import java.io.*;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.sql.*;
import java.util.*;

class UpdateInformation{
JFrame f;
JPanel p2;
JLabel l7,l8,l9,l10;
JTextField tf7,tf8,tf9,tf10;
JButton editbtn1,editbtn2 ;

UpdateInformation(){
f=new JFrame("Form");
p2=new JPanel(new GridLayout(5,2));
l7=new JLabel("Employee ID:");
l8=new JLabel("Employee Name:");
l9=new JLabel("Employee Address:");
l10=new JLabel("Salary:");
tf7=new JTextField(12);
tf8=new JTextField(12);
tf9=new JTextField(12);
tf10=new JTextField(12);
editbtn1=new JButton("Edit ");
editbtn2=new JButton("Save");

p2.add(l7);
p2.add(tf7);
p2.add(l8);
p2.add(tf8);
p2.add(l9);
p2.add(tf9);
p2.add(l10);
p2.add(tf10);
p2.add(editbtn1);
p2.add(editbtn2);

editbtn1.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent ae){
String value=tf7.getText();

try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:student");

PreparedStatement st=con.prepareStatement("select * from employee where id=?");
st.setString(1,value);
ResultSet res=st.executeQuery();
res.next();
tf7.setText(res.getString("id"));
tf8.setText(res.getString("name"));
tf9.setText(res.getString("address"));
tf10.setText(res.getString("salary")));
con.close();
}
catch(Exception e)
{
JOptionPane.showMessageDialog(p2,"Can not edit data");
}
}
});
editbtn2.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent ae){

try
{
int x=JOptionPane.showConfirmDialog(p2,"Confirm edit? All data will be replaced");
if(x==0){
try{
String value1=tf7.getText();
String value2=tf8.getText();
String value3=tf9.getText();
String value4=tf10.getText();

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:student");

Statement st=con.createStatement();
st.executeUpdate("update employee set name='"+value2+"', address='"+value3+"', salary='"+value4+"' where id='"+value1+"' ");
JOptionPane.showMessageDialog(p2,"Updated successfully");
con.close();
}
catch(Exception ex)
{
JOptionPane.showMessageDialog(p2,"Error in updating edit fields");
}
}
}
catch(Exception ex)
{
JOptionPane.showMessageDialog(p2,"Error");
}
}
});
}
void dis()
{
f.getContentPane().add(p2);
f.setTitle("Update Records");
f.setSize(350,180);
f.setVisible(true);
f.setResizable(true);
}
public static void main(String z[]){
UpdateInformation pro=new UpdateInformation();
pro.dis();
}
}


Related Tutorials/Questions & Answers:
updation problem during transaction to ms-access
updation problem during transaction to ms-access  Hey friends I am a beginner to java,and my problem is related to updation query in ms... in text fields and then updation is made in these textboxes and then updation query
updation problem during transaction to ms-access
updation problem during transaction to ms-access  Hey friends I am a beginner to java,and my problem is related to updation query in ms... in text fields and then updation is made in these textboxes and then updation query
Advertisements
updation problem during transaction to ms-access
updation problem during transaction to ms-access  Hey friends I am a beginner to java,and my problem is related to updation query in ms... in text fields and then updation is made in these textboxes and then updation query
updation problem during transaction to ms-access
updation problem during transaction to ms-access  Hey friends I am a beginner to java,and my problem is related to updation query in ms... in text fields and then updation is made in these textboxes and then updation query
MS-ACCESS Query Problem - SQL
MS-ACCESS Query Problem  hi sir i have table which is initially have empty records Deleted Attributes: Roll Name Add Age Course Class... = DriverManager.getConnection("jdbc:odbc:access"); Statement st
problem in jsp using ms-access
problem in jsp using ms-access  after starting server(tomcat) wen v... and select the driver Microsoft Access Driver(*.mdb). 3)After selecting... the driver Microsoft Access Driver(*.mdb). 3)After selecting the driver, click
ms access
ms access  how to delete the autonumber from ms access using java delete code
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 = 'data';   SELECT column_name FROM INFORMATION_SCHEMA.KEY_COLUMN
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
ms access
has to login . i already created ms access page and inserted values throught... and password" from my ms access............and detail in register(table in my ms... and password " he has to login . i already created ms access page and inserted values
ms access
has to login . i already created ms access page and inserted values throught... and password" from my ms access............and detail in register(table in my ms... and password " he has to login . i already created ms access page and inserted values
ms access
has to login . i already created ms access page and inserted values throught... and password" from my ms access............and detail in register(table in my ms... and password " he has to login . i already created ms access page and inserted values
ms access
has to login . i already created ms access page and inserted values throught... and password" from my ms access............and detail in register(table in my ms... and password " he has to login . i already created ms access page and inserted values
MS-Access
MS-Access  I am trying to upload a image to ms-acess using jsp,and my problem is that it shows some error int the browser that "java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver]COUNT field incorrect ".I think i set
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 - 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
MS Access - JSP-Servlet
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... in Connectivity in MS Access : import java.sql.*; public class
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` - JDBC
MS Access`  Hello Sir, Thank you very much for your valuable information. Actually i am doin a project to generate Hall tickets.So, I need to insert image into MS Access Database. Now the task is how to retrieve the image
J2ME connectivity to ms access
J2ME connectivity to ms access  How to establish client server connectivity to access ms access database on the server side? I have made the odbc connection. Plz help me in the coding part.. Dont know how to start
excel to ms access
excel to ms access  hello sir i am developing a application which requires extracting data from excel sheet and place in the ms access database using java programming for example: in excel sheet i have 2 columns and more than
java &ms access - JDBC
ve managed to populate the JComboBox using MS Access. The problem is only 8 per...java &ms access  Seasons Greetings, Am, creating an application for a food festival using Java swing as front end and MS access as Backend
inserting picture in ms access
inserting picture in ms access  hi i am sanatan, how to insert picture in ms access by jsp.   <%@page import="java.sql.*,java.io.*"%> <% try{ InputStream sImage; Class.forName("sun.jdbc.odbc.JdbcOdbcDriver
link hibernate to MS ACCESS database
link hibernate to MS ACCESS database  how to link hibernate to ms access database instead of sql database
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
MS Access - WebSevices
MS Access  hello sir, i am trying to write a code which should take... help in solving problem. In this example we have first created a DSN named "emp" which have access database and for images we have created a field in the table
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
Migrating from mysql to MS Access
Migrating from mysql to MS Access  Hi I am hoping for some help I need to write a conversion program (SQL statements) to import existing data in a MYSQL database to a MS Access database. any suggestions would be appreciated
accessing ms access through jsp
accessing ms access through jsp  i have 3 tables in my database employee,project,task if i put employee id the search field .i should get details from other table what all queries should i use in servlet file and i am using
a problem during add jar file javax.annotation.Resource
a problem during add jar file javax.annotation.Resource   when i use this jar file in my application i got this problem pls tell me about it Access restriction: The type Resource is not accessible due to restriction on required
 

 

 

DMCA.com