Hello
I have a problem when coding the statement
[PHP]stmt.execute("i nsert into Member values ("+mname+" ,"+mail+","+tel +")");[/PHP]
where mname, mail,tel are variables
which the user inputs them and stored in variables and then i want them to be stored in MS Access, everything is done successfully until it reached the previous statement
Here is the code
[PHP]try {
System.out.prin tln("Beginning Connection");
Class.forName(" sun.jdbc.odbc.J dbcOdbcDriver") ;
String accessFileName = "jdbc:odbc:Proj ect";
String connURL = "jdbc:odbc:;DRI VER=Microsoft Access Driver (*.mdb);DBQ="+a ccessFileName+" .mdb;PWD=";
Connection con = DriverManager.g etConnection( accessFileName) ;
Statement stmt = con.createState ment();
System.out.prin tln("Connection done successfully");
stmt.execute("C reate table Member(Name String,EMAIL String,Telephon e String)");
System.out.prin tln("Table Created");
System.out.prin tln("Please, Enter the Member Name : ");
InputStreamRead er istream = new InputStreamRead er (System.in);
BufferedReader br = new BufferedReader (istream);
try{
String mname= (br.readLine()) ;
System.out.prin tln("Please, Enter the E-Mail Address : ");
InputStreamRead er isr = new InputStreamRead er (System.in);
BufferedReader bfr = new BufferedReader (isr);
try
{
String mail= (bfr.readLine() );
try{
System.out.prin tln("Please, Enter the Telephone number : ");
InputStreamRead er ism = new InputStreamRead er (System.in);
BufferedReader bb = new BufferedReader (ism);
String tel=String.valu eOf(bb.readLine ());
stmt.execute("i nsert into Member values ("+mname+" ,"+mail+","+tel +")");
System.out.prin tln("Insertion has been completed");
stmt.execute(" select * from Member");
ResultSet rs=stmt.getResu ltSet();
if (rs != null)
while (rs.next()){
System.out.prin tln("Name: "+rs.getString( "Name")+ " E-MAIL: " + rs.getString("E MAIL")+" Telephone: "+rs.getString( "Telephone" ));
}
stmt.close();
con.close();
}
catch (IOException err)
{
System.out.prin tln("Error in reading the numbers");
}
}
catch (IOException err)
{
System.out.prin tln("Error in reading the numbers");
}
}
catch (IOException err)
{
System.out.prin tln("Error in reading the numbers");
}
}
catch (Exception err) {err.printStack Trace();}
}[/PHP]
I have a problem when coding the statement
[PHP]stmt.execute("i nsert into Member values ("+mname+" ,"+mail+","+tel +")");[/PHP]
where mname, mail,tel are variables
which the user inputs them and stored in variables and then i want them to be stored in MS Access, everything is done successfully until it reached the previous statement
Here is the code
[PHP]try {
System.out.prin tln("Beginning Connection");
Class.forName(" sun.jdbc.odbc.J dbcOdbcDriver") ;
String accessFileName = "jdbc:odbc:Proj ect";
String connURL = "jdbc:odbc:;DRI VER=Microsoft Access Driver (*.mdb);DBQ="+a ccessFileName+" .mdb;PWD=";
Connection con = DriverManager.g etConnection( accessFileName) ;
Statement stmt = con.createState ment();
System.out.prin tln("Connection done successfully");
stmt.execute("C reate table Member(Name String,EMAIL String,Telephon e String)");
System.out.prin tln("Table Created");
System.out.prin tln("Please, Enter the Member Name : ");
InputStreamRead er istream = new InputStreamRead er (System.in);
BufferedReader br = new BufferedReader (istream);
try{
String mname= (br.readLine()) ;
System.out.prin tln("Please, Enter the E-Mail Address : ");
InputStreamRead er isr = new InputStreamRead er (System.in);
BufferedReader bfr = new BufferedReader (isr);
try
{
String mail= (bfr.readLine() );
try{
System.out.prin tln("Please, Enter the Telephone number : ");
InputStreamRead er ism = new InputStreamRead er (System.in);
BufferedReader bb = new BufferedReader (ism);
String tel=String.valu eOf(bb.readLine ());
stmt.execute("i nsert into Member values ("+mname+" ,"+mail+","+tel +")");
System.out.prin tln("Insertion has been completed");
stmt.execute(" select * from Member");
ResultSet rs=stmt.getResu ltSet();
if (rs != null)
while (rs.next()){
System.out.prin tln("Name: "+rs.getString( "Name")+ " E-MAIL: " + rs.getString("E MAIL")+" Telephone: "+rs.getString( "Telephone" ));
}
stmt.close();
con.close();
}
catch (IOException err)
{
System.out.prin tln("Error in reading the numbers");
}
}
catch (IOException err)
{
System.out.prin tln("Error in reading the numbers");
}
}
catch (IOException err)
{
System.out.prin tln("Error in reading the numbers");
}
}
catch (Exception err) {err.printStack Trace();}
}[/PHP]
Comment