Click here to Skip to main content
15,891,136 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: Accessing an image on the web form Pin
TestRider27-Jan-09 19:04
TestRider27-Jan-09 19:04 
QuestionDatabinding to dynamically created textboxes Pin
gbabu1727-Jan-09 5:40
gbabu1727-Jan-09 5:40 
Questiondrop www from url Pin
munklefish27-Jan-09 5:03
munklefish27-Jan-09 5:03 
AnswerRe: drop www from url Pin
Aman Bhullar27-Jan-09 19:01
Aman Bhullar27-Jan-09 19:01 
AnswerRe: drop www from url Pin
Ashutosh Phoujdar27-Jan-09 21:40
Ashutosh Phoujdar27-Jan-09 21:40 
Question[newbie] Cannot insert null value to SQL Server identity column Pin
jon-8027-Jan-09 4:52
professionaljon-8027-Jan-09 4:52 
AnswerRe: [newbie] Cannot insert null value to SQL Server identity column Pin
SeMartens27-Jan-09 4:56
SeMartens27-Jan-09 4:56 
GeneralRe: [newbie] Cannot insert null value to SQL Server identity column Pin
jon-8027-Jan-09 7:47
professionaljon-8027-Jan-09 7:47 
Well the insert statement excludes this key, because I assumed Smile | :) , that the behavior would be similar to that as when I update the table manually, for example:

"INSERT INTO [teamwiki].[dbo].[task]\r
([category_FK1]\r 
,[sub_category_FK2]\r                         
,[ideal_delivery_date]\r                                       
,[latest_delivery_date]\r                                       
,[task_deadline]\r                                       
,[request_date]\r                                       
,[requesting_user]\r                                       
,[assigned_to]\r                                       
,[managed_by]\r                                       
,[implementor_notes]\r                                       
,[attachment] \r                                       
,[last_update]\r                                       
,[in_use])\r            
VALUES   (@category, \r                                       
@sub_category,\r                                       
@task_description,\r                                       
@priority,\r                                      
@status, \r                                       
@ideal_delivery_date,\r                                       
@latest_delivery_date,\r                                       
NULL,\r                                       
GETDATE(),\r                                       
@requesting_user,\r                                       
NULL,\r                                       
NULL,\r                                       
NULL,\r                                       
NULL,\r                                       
@in_use,\r                                       
@product)"  string


In my case, the primary key is named taskID_PK, as previously posted.

2. When I update data manually (e.g. through SQL Management Studio > right click on the table > Open table), the key is automatically incremented.

3. I created the table with an identity trigger simply using SQL Management Studio:

3.1 Taking a copy of the CREATE TABLE. Right click on table name > Script Table As > CREATE TO > New Query Window.
3.2 Dropping the table. Right click on the table name > delete.
3.3 Altering the CREATE TABLE statement to include identity:

GO
/****** Object:  Table [dbo].[task]    Script Date: 01/27/2009 19:42:34 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[task](
	[taskID] [numeric] (2, 0) identity NOT NULL,
	[task_description] [nvarchar](50) NULL,
	[date_entered] [datetime] NULL,
	[productID_FK1] [numeric](2, 0) NULL,
 CONSTRAINT [PK_task_1] PRIMARY KEY CLUSTERED 
(
	[taskID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
ALTER TABLE [dbo].[task]  WITH CHECK ADD  CONSTRAINT [FK_task_product] FOREIGN KEY([productID_FK1])
REFERENCES [dbo].[product] ([productID])
GO
ALTER TABLE [dbo].[task] CHECK CONSTRAINT [FK_task_product]


Attempted solutions
-------------------
Since the key is a primary key, it doesn't accept any NULL values; it was recommended to use identity columns as opposed to a trigger that alters the table upon insert, because "it would be a computational suicide".

Related links
--------------
Forum post[^]

Jon

GeneralRe: [newbie] Cannot insert null value to SQL Server identity column Pin
SeMartens27-Jan-09 21:18
SeMartens27-Jan-09 21:18 
QuestionHosting a .Net DataGridView in Asp .Net Pin
dptalt27-Jan-09 4:27
dptalt27-Jan-09 4:27 
AnswerRe: Hosting a .Net DataGridView in Asp .Net Pin
Christian Graus27-Jan-09 4:30
protectorChristian Graus27-Jan-09 4:30 
GeneralRe: Hosting a .Net DataGridView in Asp .Net Pin
dptalt27-Jan-09 5:03
dptalt27-Jan-09 5:03 
QuestionError updating JScript IntelliSense Pin
adelfino6927-Jan-09 4:14
adelfino6927-Jan-09 4:14 
Questionhow to fetch stock market values in asp.net application Pin
rak_kan27-Jan-09 3:21
rak_kan27-Jan-09 3:21 
AnswerRe: how to fetch stock market values in asp.net application Pin
Colin Angus Mackay27-Jan-09 3:57
Colin Angus Mackay27-Jan-09 3:57 
AnswerRe: how to fetch stock market values in asp.net application Pin
Christian Graus27-Jan-09 4:31
protectorChristian Graus27-Jan-09 4:31 
AnswerRe: how to fetch stock market values in asp.net application Pin
Ashutosh Phoujdar27-Jan-09 21:51
Ashutosh Phoujdar27-Jan-09 21:51 
QuestionProject taking long time to build. Pin
jchandramouli27-Jan-09 2:42
jchandramouli27-Jan-09 2:42 
AnswerRe: Project taking long time to build. Pin
N a v a n e e t h27-Jan-09 2:46
N a v a n e e t h27-Jan-09 2:46 
AnswerRe: Project taking long time to build. Pin
Colin Angus Mackay27-Jan-09 3:59
Colin Angus Mackay27-Jan-09 3:59 
AnswerRe: Project taking long time to build. Pin
Abhijit Jana27-Jan-09 4:02
professionalAbhijit Jana27-Jan-09 4:02 
QuestionTreeView Control Pin
Civic0627-Jan-09 2:26
Civic0627-Jan-09 2:26 
AnswerRe: TreeView Control Pin
N a v a n e e t h27-Jan-09 2:34
N a v a n e e t h27-Jan-09 2:34 
GeneralRe: TreeView Control Pin
Civic0627-Jan-09 2:46
Civic0627-Jan-09 2:46 
GeneralRe: TreeView Control Pin
N a v a n e e t h27-Jan-09 2:54
N a v a n e e t h27-Jan-09 2:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.