Hi,
If I used firt query like
"insert into UserInfo (CITY) in 'C:\\User.mdb' select CITY from RateInfo"
its inserting the city value but remailning null, is it correct.
If I used second query like
"update UserInfo set CITY = (select CITY from RateInfo) where Name = '" +
theNameInTheRowThatNeedsToBeUpdated + "';"
its showing the runtime error like
SQLException: [Microsoft][ODBC Microsoft Access Driver] The Microsoft Jet database engine cannot find the input table or query 'UserInfo'. Make sure it exists and that its name is spelled correctly.
If I used both queries like insert and update then the table2 is showing
like that.
Name Address City
ZZZZ
AAAA
UUU DDDD
EEE QQQQ
I am not getting the correct way, please watch my source code.
public static void main(String args[]){
// String url = "jdbc
dbc:user"; // Second DSN name for UserPer.mdb
String url1 = "jdbc
dbc:rate"; //First DSN name for RatePer.mdb
Connection con;
Statement stmt;
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch (java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}
try {
// con = DriverManager.getConnection(url);
con = DriverManager.getConnection(url1);
stmt = con.createStatement();
//String query = " insert into UserInfo(City) in 'C:\\UserPer.mdb'
//select City from RateInfo ";
String query1 = " update UserInfo set City = (select City from
RateInfo) where Name='"+Ahammad+"';";
// stmt.executeUpdate(query);
stmt.executeUpdate(query1);
}
stmt.close();
con.close();
}
catch (SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());
}
}
help would be apprciated,
Thanks,
Ahamed.
Originally posted by Timothy Marks:
When you execute the sql statement
"insert into UserInfo (CITY) in 'C:\\User.mdb' select CITY from RateInfo"
you are creating a new row in your database with the column CITY filled out, but the name and address will get the values of null.
If you were to use
"update UserInfo set CITY = (select CITY from RateInfo) where Name = '" +
theNameInTheRowThatNeedsToBeUpdated + "';"
you would change the value in the CITY column of UserInfo to the first result returned by the select statement.
From your description, this looks like what you want to do. Have I understood your problem correctly?