SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Other SQL Server 2008 Topics
 Primary Key is not AutoGenerating
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

vodkasoda
Starting Member

Ireland
15 Posts

Posted - 03/04/2013 :  17:40:00  Show Profile  Reply with Quote
I am new to SQL Server, but have exposure to databases on Mainframe & MS Access, but this is giving me a headache ...

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

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

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 ...

visakh16
Very Important crosS Applying yaK Herder

India
52317 Posts

Posted - 03/04/2013 :  23:58:48  Show Profile  Reply with Quote
why dont you create tables using CREATE TABLE script rather than through wizard?

ALso for inserting data use INSERT t-sql statement rather than trying to add through the grid

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

vodkasoda
Starting Member

Ireland
15 Posts

Posted - 03/05/2013 :  02:18:01  Show Profile  Reply with Quote
Well in this instance I am creating (or trying to) 1 single record for Test purposes, I have no intention of typing in every entry when I load the real data ...

I am now using nvarchar & have not specified Unique for my Key & will revisit this in future if I feel the need, for now you can close this question ...

Edited by - vodkasoda on 03/05/2013 04:25:25
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000