• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem: SQL Exception

 
Simon John
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sql Exception is thrown : java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] You cannot add or change a record because a related record is required in table 'BATCH'.

BATCH TABLE
------------
BATCHID TEXT (PRIMARY KEY)
STUDENT TABLE
-------------
FIRSTNAME TEXT
LASTNAME TEXT
YEARID TEXT
SECTION TEXT
ROLLNO TEXT (PRIMARY KEY)
BATCHID TEXT (PRIMARY KEY)
DEPTCODE TEXT (PRIMARY KEY)
ADDRESS TEXT
PHONENO TEXT
MOBILENO TEXT
EMAIL TEXT
GENDER TEXT
PASSWORD TEXT
ENROLLMENTNO TEXT
"INSERT INTO STUDENT ( FIRSTNAME , LASTNAME , YEARID , SECTION , ROLLNO , BATCHID , DEPTCODE , ADDRESS , PHONENO ,MOBILENO , EMAIL , GENDER , PASSWORD , ENROLLMENTNO ) VALUES ('"+firstName+"', '"+lastName+"', '"+yearID+"', '"+section+"', '"+rollNo+"', '"+batchID+"', '"+deptCode+"', '"+ address+"', '"+phoneNo+"', '"+mobileNo+"', '"+emailAddress+"', '"+gender+"', '"+password+"', '"+enrollmentNo+"')";
The value of the batch ID that i m passing in the above query in already present in the Batch Table
 
Simon John
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have solved the problem
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic