D
Douglas Buchanan
What am I doing wrong?
I cannot enter new data into my datagrid because the DataSet (or
StoredProcedute) does not recognize that the ID is an identity.
Therefore I get the following error;
Error: Column 'RefSourceID' does not allow nulls. Do you want to
correct the value?
It also does not recognize the default value of two of the fields.
===== What I see in the DataGrid ==
RefSourceID, RefSource, ord, hide
1, Newspaper, 0, 0
2, Television, 1, 0
(null), (null), (null), (null)
===== What I should see ===========
RefSourceID, RefSource, ord, hide
1, Newspaper, 0, 0
2, Television, 1, 0
3, (null), 0, 0
===== The table (sqls2k) ==========
CREATE TABLE [dbo].[lkp01RefSource] (
[RefSourceID] [tinyint] IDENTITY (1, 1) NOT NULL ,
[RefSource] [varchar] (25) COLLATE SQL_Latin1_General_CP1_CI_AS NOT
NULL ,
[ord] [tinyint] NOT NULL ,
[hide] [bit] NOT NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[lkp01RefSource] ADD
CONSTRAINT [DF__lkp01RefSou__ord__77BFCB91] DEFAULT (0) FOR [ord],
CONSTRAINT [DF__lkp01RefSo__hide__78B3EFCA] DEFAULT (0) FOR [hide],
CONSTRAINT [PKRefSourceID] PRIMARY KEY CLUSTERED
(
[RefSourceID]
) ON [PRIMARY]
GO
I used vb.net to create the dataAdapter, storedProcedure, and dataSet.
===== The Stored Procedure ========
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE PROCEDURE dbo.NewSelectCommandRefS
AS
SET NOCOUNT ON;
SELECT RefSourceID, RefSource, ord, hide FROM lkp01RefSource ORDER BY
ord, RefSource
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
===== The Code ====================
Private Sub btnFill_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnFill.Click
Me.SqlDataAdapter1.Fill(DsRefSource1, "lkp01RefSource")
End Sub
===== End of sample code ==========
What am I doing wrong? What should I be doing?
I cannot enter new data into my datagrid because the DataSet (or
StoredProcedute) does not recognize that the ID is an identity.
Therefore I get the following error;
Error: Column 'RefSourceID' does not allow nulls. Do you want to
correct the value?
It also does not recognize the default value of two of the fields.
===== What I see in the DataGrid ==
RefSourceID, RefSource, ord, hide
1, Newspaper, 0, 0
2, Television, 1, 0
(null), (null), (null), (null)
===== What I should see ===========
RefSourceID, RefSource, ord, hide
1, Newspaper, 0, 0
2, Television, 1, 0
3, (null), 0, 0
===== The table (sqls2k) ==========
CREATE TABLE [dbo].[lkp01RefSource] (
[RefSourceID] [tinyint] IDENTITY (1, 1) NOT NULL ,
[RefSource] [varchar] (25) COLLATE SQL_Latin1_General_CP1_CI_AS NOT
NULL ,
[ord] [tinyint] NOT NULL ,
[hide] [bit] NOT NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[lkp01RefSource] ADD
CONSTRAINT [DF__lkp01RefSou__ord__77BFCB91] DEFAULT (0) FOR [ord],
CONSTRAINT [DF__lkp01RefSo__hide__78B3EFCA] DEFAULT (0) FOR [hide],
CONSTRAINT [PKRefSourceID] PRIMARY KEY CLUSTERED
(
[RefSourceID]
) ON [PRIMARY]
GO
I used vb.net to create the dataAdapter, storedProcedure, and dataSet.
===== The Stored Procedure ========
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE PROCEDURE dbo.NewSelectCommandRefS
AS
SET NOCOUNT ON;
SELECT RefSourceID, RefSource, ord, hide FROM lkp01RefSource ORDER BY
ord, RefSource
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
===== The Code ====================
Private Sub btnFill_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnFill.Click
Me.SqlDataAdapter1.Fill(DsRefSource1, "lkp01RefSource")
End Sub
===== End of sample code ==========
What am I doing wrong? What should I be doing?