Database probelm:No Data found
well,im not soooo familiar with JDBC concepts,especially dealing with MS Access 2007
well,im working on Library management in Frames and i have to add students for that i took add button and i have student id and student name to add in database and i have dont all required [connecting ODBC etc..] and i wrote the code,but when i click add,it is showing me a error box sayong "NO DATA FOUND" please help me ASAP...this is my code:-
Code:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import java.io.*;
import java.awt.event.*;
import java.sql.*;
class students extends Frame implements ActionListener,ItemListener{
Button ad,bck;
Label stn,stid,hd,conf;
TextField sin,sii;
Choice up;
ResultSet rs;
students(){
up=new Choice();
Font f=new Font("Arial",Font.BOLD,15);
Font n=new Font("Arial",Font.PLAIN,15);
Font g=new Font("Arial",Font.BOLD+Font.ITALIC,30);
hd=new Label("STUDENTs SESSION",Label.CENTER);
stid=new Label("Student ID:",Label.LEFT);
stn=new Label("Student Name:",Label.LEFT);
conf=new Label();
sii=new TextField(20);
sin=new TextField(20);
ad=new Button("Add");
bck=new Button("Back");
hd.setFont(g);
bck.setFont(f);
ad.setFont(n);
stn.setFont(f);
conf.setFont(f);
stid.setFont(f);
sii.setFont(n);
sin.setFont(n);
hd.setBounds(80,50,300,100);
stid.setBounds(80,200,100,40);
stn.setBounds(60,245,120,40);
sii.setBounds(180,205,150,26);
sin.setBounds(180,250,150,26);
up.setBounds(180,300,150,26);
conf.setBounds(180,350,200,26);
bck.setBounds(100,410,60,40);
ad.setBounds(330,410,60,40);
setLayout(null);
add(up);
add(ad);
add(bck);
add(stn);
add(stid);
add(hd);
add(sin);
add(sii);
add(conf);
ad.addActionListener(this);
up.addItemListener(this);
bck.addActionListener(this);
}
public void itemStateChanged(ItemEvent e){
repaint();
}
public void actionPerformed(ActionEvent ae){
if(ae.getSource()==ad){
addOperation();
String snme=sin.getText();
up.add(snme);
}
if(ae.getSource()==bck){
GetFrame2 f2=new GetFrame2();
f2.setVisible(true);
f2.setSize(500,500);
this.dispose();
}
}
public void addOperation()
{
try
{
//Load Jdbc Odbc Driver
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:mydb");
String sql = "INSERT INTO mydb (ID,Name) " +
"Values ('"+sii.getText()+"'," +
"'"+sin.getText()+"')";
Integer.parseInt(sii.getText());
Statement st = con.createStatement();
st.execute(sql);
}
catch(Exception e)
{
e.printStackTrace();
}
}
public static void main(String args[]){
students sts=new students();
}
}
Re: Database probelm:No Data found
Use code tags, not quote tags, for posting code.
db
Re: Database probelm:No Data found
ok..now done..please help me...