D
Daniel Jeffrey
Hello,
I am new to ADO.NET (2.0) and I am trying my hardest to figure out the best
ways to do things, but I just keep getting stuck.
I have a DataSet that has a Header and Details configuration with the
relevant joins.
I have 2 DataAdapters, 1 for the Header and 1 For the Detail.
It is all working, unless I add 2 rows to the detail then save.
1 row at a time, and it works fine, the identity column is automatically
updated with the next identity value.
However when I add 2 rows, the first row is posted, and the 2nd row returns
errors about not being Unique.
Can anyone please let me know what I am doing wrong?
Should I be manually seeding these values before post?
DataSet Update Command
TaskAdapter.Update(dsTask, "TASK");
TaskNotesAdapter.Update(dsTask, "TASK_NOTES");
The Insert Statement that was generated is below.
INSERT INTO [TASK_ATTACHMENTS] ([NOTEID], [TASKID], [TITLE],
[ORIGINAL_FILENAME], [ATTACHMENT]) VALUES (@NOTEID, @TASKID, @TITLE, @p1,
@ATTACHMENT);
SELECT RECORDID, NOTEID, TASKID, TITLE, ORIGINAL_FILENAME, ATTACHMENT FROM
TASK_ATTACHMENTS WHERE (RECORDID = SCOPE_IDENTITY())
Table is below
CREATE TABLE [dbo].[TASK_NOTES](
[NOTEID] [int] IDENTITY(1,1) NOT NULL,
[TASKID] [int] NOT NULL,
[NOTEDATE] [datetime] NOT NULL DEFAULT (getdate()),
[ENTEREDBY] [varchar](30) NULL,
[STATUSID] [int] NOT NULL,
[NOTETYPE] [int] NOT NULL,
[NOTES] [varchar](max) NULL,
[SENDEMAIL] [char](1) NOT NULL DEFAULT ('N'),
[IS_QUESTION] [char](1) NOT NULL DEFAULT ('N'),
[QUESTION_USERCODE] [varchar](30) NULL,
[RESPONSE_RECEIVED] [char](1) NOT NULL DEFAULT ('N'),
[RESPONSE_NOTEID] [int] NULL,
PRIMARY KEY CLUSTERED
(
[NOTEID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY =
OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
I am new to ADO.NET (2.0) and I am trying my hardest to figure out the best
ways to do things, but I just keep getting stuck.
I have a DataSet that has a Header and Details configuration with the
relevant joins.
I have 2 DataAdapters, 1 for the Header and 1 For the Detail.
It is all working, unless I add 2 rows to the detail then save.
1 row at a time, and it works fine, the identity column is automatically
updated with the next identity value.
However when I add 2 rows, the first row is posted, and the 2nd row returns
errors about not being Unique.
Can anyone please let me know what I am doing wrong?
Should I be manually seeding these values before post?
DataSet Update Command
TaskAdapter.Update(dsTask, "TASK");
TaskNotesAdapter.Update(dsTask, "TASK_NOTES");
The Insert Statement that was generated is below.
INSERT INTO [TASK_ATTACHMENTS] ([NOTEID], [TASKID], [TITLE],
[ORIGINAL_FILENAME], [ATTACHMENT]) VALUES (@NOTEID, @TASKID, @TITLE, @p1,
@ATTACHMENT);
SELECT RECORDID, NOTEID, TASKID, TITLE, ORIGINAL_FILENAME, ATTACHMENT FROM
TASK_ATTACHMENTS WHERE (RECORDID = SCOPE_IDENTITY())
Table is below
CREATE TABLE [dbo].[TASK_NOTES](
[NOTEID] [int] IDENTITY(1,1) NOT NULL,
[TASKID] [int] NOT NULL,
[NOTEDATE] [datetime] NOT NULL DEFAULT (getdate()),
[ENTEREDBY] [varchar](30) NULL,
[STATUSID] [int] NOT NULL,
[NOTETYPE] [int] NOT NULL,
[NOTES] [varchar](max) NULL,
[SENDEMAIL] [char](1) NOT NULL DEFAULT ('N'),
[IS_QUESTION] [char](1) NOT NULL DEFAULT ('N'),
[QUESTION_USERCODE] [varchar](30) NULL,
[RESPONSE_RECEIVED] [char](1) NOT NULL DEFAULT ('N'),
[RESPONSE_NOTEID] [int] NULL,
PRIMARY KEY CLUSTERED
(
[NOTEID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY =
OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]