I need to retreive my id key from an Access database and compare it to the current record I'm working on how do I go about doing that, this is what I've come up with so far and this doesn't seem to work. <br>
<br>
docketNum is within my access db and fileNum is the current record I'm working with, I want to find out if this records exists this way I know if I need to perform an UPDATE or an INSERT? Am I on the right track with this?<br>
<br>
I also get an error when I run it: <br>
SQLException: General Error<br>
<br>
<br>
String find = "SELECT docketNum FROM caseInfo WHERE docketNum = '" +fileNum+"'";<br>
try<br>
{ <br>
con = DriverManager.getConnection (url,"",""<br>
stmt = con.createStatement(); <br>
ResultSet ts = stmt.executeQuery(find);<br>
// this prints the correct text<br>
System.out.println(ts); <br>
<br>
// these two println do not print out <br>
while ( ts.next()){<br>
v = ts.getString(1);<br>
System.out.println(v);<br>
System.out.println(find);<br>
}<br>
System.out.println(v);<br>
stmt.close();<br>
con.close();<br>
<br>
<br>
}catch (SQLException ex){<br>
System.err.println("SQLException: "+ ex.getMessage());<br>
} <br>
<br>
<br>
if ( v == fileNum )<br>
<br>
String query2 =("UPDATE caseInfo,<br>
+ "SET caseName = getAsSQLString(labelcaseName),"<br>
+ "evalDate = getAsSQLString(labelevalDate),"<br>
+ "docketNum = getAsSQLString(labelfileNum)" <br>
+ "WHERE docketNum = fileNum" <br>
<br>
else <br>
<br>
<br>
String query = "INSERT INTO caseInfo(caseName, evalDate, docketNum, "<br>
<br>
<br>
// rest of query, etc.<br>
<p> Courtney<br><a href=mailto: ceaton@lrp.com> ceaton@lrp.com</a><br><a href= > </a><br>
<br>
docketNum is within my access db and fileNum is the current record I'm working with, I want to find out if this records exists this way I know if I need to perform an UPDATE or an INSERT? Am I on the right track with this?<br>
<br>
I also get an error when I run it: <br>
SQLException: General Error<br>
<br>
<br>
String find = "SELECT docketNum FROM caseInfo WHERE docketNum = '" +fileNum+"'";<br>
try<br>
{ <br>
con = DriverManager.getConnection (url,"",""<br>
stmt = con.createStatement(); <br>
ResultSet ts = stmt.executeQuery(find);<br>
// this prints the correct text<br>
System.out.println(ts); <br>
<br>
// these two println do not print out <br>
while ( ts.next()){<br>
v = ts.getString(1);<br>
System.out.println(v);<br>
System.out.println(find);<br>
}<br>
System.out.println(v);<br>
stmt.close();<br>
con.close();<br>
<br>
<br>
}catch (SQLException ex){<br>
System.err.println("SQLException: "+ ex.getMessage());<br>
} <br>
<br>
<br>
if ( v == fileNum )<br>
<br>
String query2 =("UPDATE caseInfo,<br>
+ "SET caseName = getAsSQLString(labelcaseName),"<br>
+ "evalDate = getAsSQLString(labelevalDate),"<br>
+ "docketNum = getAsSQLString(labelfileNum)" <br>
+ "WHERE docketNum = fileNum" <br>
<br>
else <br>
<br>
<br>
String query = "INSERT INTO caseInfo(caseName, evalDate, docketNum, "<br>
<br>
<br>
// rest of query, etc.<br>
<p> Courtney<br><a href=mailto: ceaton@lrp.com> ceaton@lrp.com</a><br><a href= > </a><br>