M
Mervin Williams
I have several tables involved in my application, but the two in question
here are the company and address tables. The company table has
business_address_id and mailing_address_id columns, which are both foreign
keys to the address table.
So, the stored procedure to which my SelectCommand points to reads as:
ALTER PROCEDURE dbo.CompanyInfoByCompanyID
(
@companyid int
)
AS
SET NOCOUNT ON
SELECT * FROM Company WHERE company_id = @companyid
SELECT * FROM Address
WHERE (address_id IN (Select business_address_id From
Company Where company_id = @companyid))
OR (address_id IN (Select mailing_address_id From Company
Where company_id = @companyid))
RETURN
Whenever I attempt to add a new row into the Address table using my
daAddress dataset, the update works fine and even enters a new row inside
the Address table. However, when I attempt to refresh my datagrid by
calling the Fill() method on the Address adapter I get the following error:
Exception Details: System.Data.SqlClient.SqlException: UPDATE statement
conflicted with COLUMN FOREIGN KEY constraint 'Address_Company_FK1'. The
conflict occurred in database 'OFS', table 'Address', column 'address_id'.
I placed the Find() call in a try/catch block, and upon closer inspection
discovered this error message:
DataSet errors: dsCompanyInfo
Table: Address
Row Error: Column 'zip' does not allow DBNull.Value.
Now, the zip column is indeed populated upon calling the Update() method,
and it is populated in the database. So I have no idea where this error
message is coming from.
Your assistance would be greatly appreciated,
Mervin Williams
here are the company and address tables. The company table has
business_address_id and mailing_address_id columns, which are both foreign
keys to the address table.
So, the stored procedure to which my SelectCommand points to reads as:
ALTER PROCEDURE dbo.CompanyInfoByCompanyID
(
@companyid int
)
AS
SET NOCOUNT ON
SELECT * FROM Company WHERE company_id = @companyid
SELECT * FROM Address
WHERE (address_id IN (Select business_address_id From
Company Where company_id = @companyid))
OR (address_id IN (Select mailing_address_id From Company
Where company_id = @companyid))
RETURN
Whenever I attempt to add a new row into the Address table using my
daAddress dataset, the update works fine and even enters a new row inside
the Address table. However, when I attempt to refresh my datagrid by
calling the Fill() method on the Address adapter I get the following error:
Exception Details: System.Data.SqlClient.SqlException: UPDATE statement
conflicted with COLUMN FOREIGN KEY constraint 'Address_Company_FK1'. The
conflict occurred in database 'OFS', table 'Address', column 'address_id'.
I placed the Find() call in a try/catch block, and upon closer inspection
discovered this error message:
DataSet errors: dsCompanyInfo
Table: Address
Row Error: Column 'zip' does not allow DBNull.Value.
Now, the zip column is indeed populated upon calling the Update() method,
and it is populated in the database. So I have no idea where this error
message is coming from.
Your assistance would be greatly appreciated,
Mervin Williams