Auto Increment...???

Err, that is usually when you add a new field that it's -1, -2, etc. when you save the DBMS will assign a value. So in other words, you add a new field and it's ID is -1, you add another it's -2, then you save and it is COMMITTED, at that point is will no longer be negative, else post code and I'll help you.

Thanx Gnome... Just, how do I fix it...? I have now recreated the DB using the SQL Express 2005 Manager thing, and in the DB it is working fine, but when using the forms, the -1, -2 thing happens... Is it in the DB where I should change something, or in the VB itself...?
 
...and when using linked tables, it saves the -1, -2 , etc. in the LINK collumn of the secondary table...?!?! I really don't know what to do...
 
Did someone encoutered the same problem perhaps...? Is it a small thing to change in the code...? I am struggling with this stupid thing...
 
Are the negative ID values being saved to the table afterwards? Or do the entries only have a negative ID while the "batch" hasn't been committed to the DB yet?
 
Are the negative ID values being saved to the table afterwards? Or do the entries only have a negative ID while the "batch" hasn't been committed to the DB yet?

It saves it in the secondary table as negative values, but in the primary table afterwards as positives, and that messes up the idea of the link
 
This is the code of the Primary Table:

Code:
BEGIN TRANSACTION
SET QUOTED_IDENTIFIER ON
SET ARITHABORT ON
SET NUMERIC_ROUNDABORT OFF
SET CONCAT_NULL_YIELDS_NULL ON
SET ANSI_NULLS ON
SET ANSI_PADDING ON
SET ANSI_WARNINGS ON
COMMIT
BEGIN TRANSACTION
GO
ALTER TABLE dbo.UInfo
	DROP CONSTRAINT PK_UInfo
GO
COMMIT

And this is the code of the secondary table:

Code:
BEGIN TRANSACTION
SET QUOTED_IDENTIFIER ON
SET ARITHABORT ON
SET NUMERIC_ROUNDABORT OFF
SET CONCAT_NULL_YIELDS_NULL ON
SET ANSI_NULLS ON
SET ANSI_PADDING ON
SET ANSI_WARNINGS ON
COMMIT
BEGIN TRANSACTION
GO
ALTER TABLE dbo.UBill ADD CONSTRAINT
	PK_UBill PRIMARY KEY CLUSTERED 
	(
	ID
	) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]

GO
COMMIT
 
I have done the foreign key thing, but still throws the Negatve ID into the Link field... Where as it should be in UInfo -> ID = 3 then in UBill -> Link = 3. But it keeps on displaying the damn ID as -1, -2, -3. In Access its freakin easy to do, but I am struggling so much with the SQL / VB combination...
 
I think, like dequadin said, we need to see some VB.NET code which you use to insert the data into the database. Maybe something's going horrible wrong there...
 
Top
Sign up to the MyBroadband newsletter
X