473,396 Members | 1,892 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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

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

Nov 15 '05 #1
7 1133
It just shouldn't do this, if the primary key is autonumbered. Have you
ensured the database is set to autoincrement?
"lewi" <bj******@willapabay.org> wrote in message
news:vt************@corp.supernews.com...
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...

Nov 15 '05 #2
You might show us command definition.

--
Miha Markic - RightHand .NET consulting & development
miha at rthand com

"lewi" <bj******@willapabay.org> wrote in message
news:vt************@corp.supernews.com...
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...

Nov 15 '05 #3
> 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...
Nov 15 '05 #4
> 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...
Nov 15 '05 #5
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))
--
Miha Markic - RightHand .NET consulting & development
miha at rthand com

"lewi" <bj******@willapabay.org> wrote in message
news:vt************@corp.supernews.com...
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...

Nov 15 '05 #6
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
"lewi" <bj******@willapabay.org> wrote in message
news:vt************@corp.supernews.com...
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...

Nov 15 '05 #7
> 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...
Nov 15 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
by: Jaraba | last post by:
I am working in a project that I need to parse an arrayt an select records based upon the values parsed. I used the functions developed by Knut Stolze in his article 'Parsing Strings'. I am...
7
by: ebindia0041 | last post by:
This is like the bug from hell. It is kind of hard to explain, so please bear with me. Background Info: SQL Server 7.0, Asp.net 1.1 with c# I'm inserting simple records into a table. But one...
13
by: imnewtoaccess | last post by:
Hi, I am getting errors while inserting records in one table from another. These are the structures of two tables : file51tm_new RecordType Text
20
by: dav3 | last post by:
Alright folks I am in need of a lil guidance/assistance here. I have a program which reads in a txt file. This txt file contains lines of the form January 3, 2007, 85.8 Now each line of the txt...
5
by: dos360 | last post by:
Hello, I have two tables, one is a list of activities, the other a list of participants. I want to insert one record in the activities table and then using its identity column as foreign key, I...
2
by: AlexanderDeLarge | last post by:
Hi! I got a problem that's driving me crazy and I'm desperately in need of help. I'll explain my scenario: I'm doing a database driven site for a band, I got these tables for their discography...
5
by: rando1000 | last post by:
Okay, here's my situation. I need to loop through a file, inserting records based on a number field (in order) and if the character in a certain field = "##", I need to insert a blank record. ...
8
by: rando1000 | last post by:
I have a VBA program that loops through a table of table names and imports the records from those tables into another table. In some instances (not every time), the inserting gets confused, and I...
3
by: simple simon | last post by:
How would I insert into multiple related tables using a table valued parameter? Is there any way to do this without using a WHILE loop? I know how to insert from a table valued parameter into one...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.