I just realized what is causing it. I am using an InsteadOf Trigger in SQL Server for Inserts on this table. The Trigger checks for a condition and then either Raises and error or completes the Insert using the Inserted table. It seems that the .Net does not catch any sql errors that occur on statements executed in a trigger. Here is my trigger.
ALTER Trigger trgHouseholdPrimaryCheck
ON tblHousehold
Instead of Insert
As
Declare @Relation varchar(20)
Declare @CaseId integer
Set @Relation = (Select Household_Relationship From Inserted)
Set @CaseId = (Select Household_CaseId From Inserted)
Select Household_Id From tblHousehold Where Household_CaseId = @CaseId And Household_Relationship
= 'Primary Client'
If @@Rowcount > 0 And @Relation = 'Primary Client'
Begin
RAISERROR(50001,16,1)
end
Else
INSERT INTO [CaseManagement].[dbo].[tblHousehold]([Household_CaseId], [Household_Active],
[Household_FirstName], [Household_LastName], [Household_MiddleName], [Household_SuffixName],
[Household_Relationship], [Household_HomePhone], [Household_WorkPhone], [Household_ContactPhone],
[Household_CellPhone], [Household_DateAdded], [Household_InactiveDate], [Household_MailStreetPo],
[Household_MailAptNum], [Household_MailCity], [Household_MailState], [Household_MailZip], [Household_SSN],
[Household_SecureRoom], [Household_FraudRisk], [Household_EmploymentTraining], [Household_WorkRestrictions],
[Household_WorkLimitations], [Household_MaritalStatus], [Household_DOB], [Household_School],
[Household_Grade], [Household_Felony], [Household_FelonyDetails], [Household_ParoleProbation],
[Household_ParoleProbationOfficer], [Household_ParoleProbationAddress], [Household_ParoleProbationCity],
[Household_ParoleProbationState], [Household_ParoleProbationZip], [Household_ParoleProbationDetails],
[Household_BranchofMilitary], [Household_RankAtDischarge], [Household_MilitaryStartDate],
[Household_MilitaryEndDate], [Household_DischargeType], [Household_Comments], [Household_UpdatedBy],
[Household_UpdatedOn], [Household_CreatedBy], [Household_CreatedOn])SELECT [Household_CaseId],
[Household_Active], [Household_FirstName], [Household_LastName], [Household_MiddleName],
[Household_SuffixName], [Household_Relationship], [Household_HomePhone], [Household_WorkPhone],
[Household_ContactPhone], [Household_CellPhone], [Household_DateAdded], [Household_InactiveDate],
[Household_MailStreetPo], [Household_MailAptNum], [Household_MailCity], [Household_MailState],
[Household_MailZip], [Household_SSN], [Household_SecureRoom], [Household_FraudRisk],
[Household_EmploymentTraining], [Household_WorkRestrictions], [Household_WorkLimitations],
[Household_MaritalStatus], [Household_DOB], [Household_School], [Household_Grade], [Household_Felony],
[Household_FelonyDetails], [Household_ParoleProbation], [Household_ParoleProbationOfficer],
[Household_ParoleProbationAddress], [Household_ParoleProbationCity], [Household_ParoleProbationState],
[Household_ParoleProbationZip], [Household_ParoleProbationDetails], [Household_BranchofMilitary],
[Household_RankAtDischarge], [Household_MilitaryStartDate], [Household_MilitaryEndDate],
[Household_DischargeType], [Household_Comments], [Household_UpdatedBy], [Household_UpdatedOn],
[Household_CreatedBy], [Household_CreatedOn] FROM Inserted
Sorry, I feel stupid that I did not catch this right off. I guess I will have to use @@ERROR in the stored procedure that fires the trigger and then use a return value to send error info. If you know of a way to trap sql errors in vb.net from a statement in a trigger please let me know.
Manch