powerfx
Admiral
- Registriert
- Apr. 2009
- Beiträge
- 9.351
Hallo,
der SQL Server (über Visual Studio) will irgendwie nicht so wie ich.
Ich habe eine LocalDB mit ein paar Tabellen. Als Beispiel diese zwei (etwas verkürzt):
und
[Country] ist bereits gefüllt und soll auch momentan gar nicht geändert werden.
Fülle ich jetzt bei [Card] in einer Zeile alle Felder aus, die kein FK sind, kann der Datensatz problemlos gespeichert werden. Bei jedem FK (die sind vom Prinzip alle gleich), also etwa "DE" als CountryID, kommt aber Folgendes:
Was stimmt denn hier mit den FKs nicht?
der SQL Server (über Visual Studio) will irgendwie nicht so wie ich.
Ich habe eine LocalDB mit ein paar Tabellen. Als Beispiel diese zwei (etwas verkürzt):
Code:
CREATE TABLE [dbo].[Card] (
[Id] INT IDENTITY (1, 1) NOT NULL,
[CardNo] VARCHAR (15) NOT NULL,
[ValidUntil] DATE NOT NULL,
[RCountryID] CHAR (2) NULL,
PRIMARY KEY CLUSTERED ([Id] ASC),
CONSTRAINT [FK_Card_Country] FOREIGN KEY ([RCountryID]) REFERENCES [dbo].[Country] ([CountryID])
);
Code:
CREATE TABLE [dbo].[Country] (
[CountryID] CHAR (2) NOT NULL,
[CountryName] NVARCHAR (60) NOT NULL,
PRIMARY KEY CLUSTERED ([CountryID] ASC)
);
Fülle ich jetzt bei [Card] in einer Zeile alle Felder aus, die kein FK sind, kann der Datensatz problemlos gespeichert werden. Bei jedem FK (die sind vom Prinzip alle gleich), also etwa "DE" als CountryID, kommt aber Folgendes:
The data in row 1 was not committed.
Error Source: .Net SqlClient Data Provider.
Error Message: The connection is broken and recovery is not possible. The client driver attempted to recover the connection one or more times and all attempts failed.
Was stimmt denn hier mit den FKs nicht?