這是我從中獲取信息的地方,當我選擇地址時,它會填充所有信息 ,但是當我嘗試在刪除租戶後向租戶表添加租戶時,問題就開始了。此表不再顯示所有addressID列,所以我試圖插入AddressID以及屬性表。我希望這是有道理的 我不能插入圖片,但這裏是它看起來像什麼時,我選擇了一個屬性,rentals插入聲明難度
if ((evt.getStateChange() == java.awt.event.ItemEvent.SELECTED) &&
(PropertyComboBox.getSelectedIndex() != 0))
{
Address = (String) PropertyComboBox.getSelectedItem();
try {
myResultSet = myStatement.executeQuery(
"SELECT Property.Address,Property.AddressID,Property.RentAmt, Renter.RenterID, Renter.AddressID, Renter.FirstName, Renter.LastName, Renter.CellPhone, Renter.DepositPaid,Renter.DepositAmtPaid " +
"FROM Property, Renter " +
"WHERE Property.Address = '" + Address + "'" + "AND Renter.AddressID = Property.AddressID");
if (myResultSet.next())
{
renterID = (myResultSet.getString("Renter.RenterID"));
addressID = (myResultSet.getString("Property.AddressID"));
txtRentAmt.setText(myResultSet.getString("Property.RentAmt"));
txtShowAddressID.setText(myResultSet.getString("Property.AddressID"));
txtShowRenterID.setText(myResultSet.getString("Renter.RenterID"));
txtFirstName.setText(myResultSet.getString("Renter.FirstName"));
txtLastName.setText(myResultSet.getString("Renter.LastName"));
txtCellPhone.setText(myResultSet.getString("Renter.CellPhone"));
txtDepositPaid.setText(myResultSet.getString("Renter.DepositPaid"));
txtDepositAmtPaid.setText(myResultSet.getString("Renter.DepositAmtPaid"));
if(myResultSet.getString("Renter.DepositPaid") == ("Y"))
{
txtDepositPaid.setText("Y");
}
else
{
txtDepositPaid.setText("N");
}
}
}
有人可以幫助我?我試圖從netbeans jform插入一個新的承租人 到我的數據庫中。從屬性表中的AddressID (PK,自動遞增)應自動 插入承租表AddressID(FK,自動遞增(所以我 思想)
,如果我用這個語句,但隨後它會插入addressID顯示爲 NULL,而不是AddressID從屬性表,這是我所需要的。香港專業教育學院 這方面的工作,因爲週六,消化道出血請幫幫忙!很簡單,但 我無法弄清楚
ls_query = "INSERT INTO Renter (FirstName,LastName,CellPhone,DepositPaid,DepositAmtPaid)" + " VALUES (" + addressID + ",'" + addFirstName + "','" + addLastName + "','" + addCellPhone + "','" + addDepositPaid + "'," + addDepositAmtPaid + ")" + " WHERE Property.AddressID = " + addressID ;
它不能更新,我試過。這是因爲當我刪除一個租戶時,它實際上刪除了整個記錄,因此我需要再次在租用表中將任何給定的propertyID插入到信息中。 – TraciBee
propertyID?請解釋你的問題好一點,現在還不清楚 – arieljuod
對不起,我的意思是AddressID。 – TraciBee