I am trying to insert information into an Access Table. If I hard code the variable information in, the insert statement works but when I assign the value of the ID number into a method to get a new number the update statement does not work. Any ideas??
This is the method I am calling to do the update:
WITHOUT CODE TAGS
public void addObject(){
int qID = getNewQID();\\get new ID number
System.out.println(qID);\\Used as a check and this is working
String qText = "Does this work yet?";
String qType = "false";
int qCorrect = 2;
String sql2 = "INSERT INTO Question(qID, qText, qType, qCorrect) VALUES("+ ID + ",'" + qText + "'," + qType + "," + qCorrect + ")";
//Send insert query to DataAccess Class to process
dataAccess.runUpdateQuery(sql2);
This is the method to get the NewID number:
public int getNewQID(){
WITH CODE TAGS
This is the method that should update the information in the Database:
public void runUpdateQuery(String sql){
try{
openConnection();//Open the Connection
stmt = conn.createStatement();//Create Statement Object
int s = stmt.executeUpdate(sql);
closeConnection();//Close Connection
}catch(SQLException sqle) {
System.out.print("Error in DataAccess: ");
System.err.println(sqle);
}//end try/catch
}//end runUpdateQuery
[ November 03, 2003: Message edited by: Gregg Bolinger ]