Quantcast
Channel: SQL Server Compact Forum
Viewing all articles
Browse latest Browse all 193

How to AutoGenerate the Primary Key

$
0
0

Databases should come with a health warning !!!

I am using VB2010 Express and used Project Add New Item to add a SQLCE 3.5 Database.

I then created 2 Tables by right clicking on the Tables tab in Database Explorer, Leagues & Teams.

I have used the Solution Explorer to open the DataSet and add a Foreign Key. This is what I now have :

Table1 : Leagues

ID -  PK, AutoIncrement = True, 1, 1, DataType = System.Int32, Unique = True

Name

Table2 : Teams

ID -  PK, AutoIncrement = True, 1, 1, DataType = System.Int32, Unique = True

Name

LeagueID - FK, AutoIncrement = False, DataType = System.Int32, Unique = False

However, if I right-click on the Table name in Database Explorer & choose Show Table Data, so I can enter a Test entry, it gets rejected with an error message telling me that the ID column cannot be Null ... so why is it not AutoIncrementing ?!? This happens if I try to enter a Test entry into either Table ...


Viewing all articles
Browse latest Browse all 193

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>