Quest: Inserting records into a table with Pri Key set from ASP.NET app...

  • Thread starter Thread starter lewi
  • Start date Start date
L

lewi

I have a ASP.NET app that I want to add user login data and use a Primary
Key for an UserID number now I tried INSERT INTO SQL statement(I didn't
include the Primay Key column in both (...) for the stamement) but the
ASP.NET app debugger show that the statement is trying to set the Primay Key
column of the record to NULL and not the next key number(this case 0 or 1 -
whatever it should gives the first record)...

What is going on here?

Any help...
 
It just shouldn't do this, if the primary key is autonumbered. Have you
ensured the database is set to autoincrement?
 
It just shouldn't do this, if the primary key is autonumbered. Have you
ensured the database is set to autoincrement?
That is what I thought... But where would I set autonumbering... I am using
MSDE that comes w/ VS.NET 2002 Pro...

Any more help...
 
You might show us command definition.
This is what the SQL cmd looks like after all the string appending...

INSERT INTO USERS (Username, Password) VALUES ('UserText', 'PasswordsText');

Username and Password are two column in the USERS table and UserText is any
string typed in the Username enter box by user(me - thus no validation yet)
on the .aspx page and same with PasswordsText for the password...

Any more help...
 
How do you create the table in first place?
CREATE TABLE dbo.Table2
(
Id int NOT NULL IDENTITY (1, 1),
tubo varchar(50) NULL
) ON [PRIMARY]

Here is a sample sql command. (note Identity(1, 1))
 
Lewi,

If you are using a dataset, you can the PrimaryKey Column.AutoIncrement =
true. This will automaticaly create the next primary key value when you
create new row().

hope this helps

Marco
 
How do you create the table in first place?
I use table design mode but I just look at the designer once more and for an
Identity setting and setting it to YES make two other options valid the Seed
and Increment both set to 1 by default...

So everythings working out now...

Thanks...
 
Back
Top