Table adapter - Is it necessary for linking or reference tables

asp.net , sql server 2005 , visual studio 2005 Wellington, New Zealand
  • 11 years ago
    [MS SQL Server 2005, Visual Studio 2005, ASP.Net 2.0(with VB.net coding) website] Hi, I have a brand table which is inter-related with many other tables. SQL generation code below. /****** Object: Table [Product].[Articles] Script Date: 03/27/2009 09:29:25 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [Product].[Articles]( [ArticleID] [int] IDENTITY(1,1) NOT NULL, [Article] [nvarchar](1000) NOT NULL, CONSTRAINT [PK_Articles] PRIMARY KEY CLUSTERED ( [ArticleID] 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 /****** Object: Table [Product].[FilePaths] Script Date: 03/27/2009 09:29:27 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO SET ANSI_PADDING ON GO CREATE TABLE [Product].[FilePaths]( [FilePathID] [int] IDENTITY(1,1) NOT NULL, [Name] [varchar](30) NOT NULL, [FilePath] [varchar](50) NOT NULL, CONSTRAINT [PK_FilePaths] PRIMARY KEY CLUSTERED ( [FilePathID] 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 SET ANSI_PADDING OFF GO /****** Object: Table [Product].[BrandsArticles] Script Date: 03/27/2009 09:29:25 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [Product].[BrandsArticles]( [BrandID] [int] NOT NULL CONSTRAINT [DF_ArticleStructure_BrandID] DEFAULT ((0)), [ArticleID] [int] NOT NULL, CONSTRAINT [PK_BrandsArticles] PRIMARY KEY CLUSTERED ( [ArticleID] ASC, [BrandID] 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 /****** Object: Table [Product].[Brands] Script Date: 03/27/2009 09:29:25 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO SET ANSI_PADDING ON GO CREATE TABLE [Product].[Brands]( [BrandID] [int] IDENTITY(1,1) NOT NULL, [Name] [varchar](40) NOT NULL, [BrandLogoImageFilePath] [int] NOT NULL, [BrandLogoImageName] [varchar](40) NOT NULL, [LargeImageFilePath] [int] NULL, [LargeImageName] [varchar](40) NULL, [Story] [varchar](1000) NOT NULL, [IsActive] [bit] NOT NULL CONSTRAINT [DF_Brands_IsActive] DEFAULT ((1)), CONSTRAINT [PK_Brands] PRIMARY KEY NONCLUSTERED ( [BrandID] 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 SET ANSI_PADDING OFF GO EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'True = Active; False = Inactive;' , @level0type=N'SCHEMA',@level0name=N'Product', @level1type=N'TABLE',@level1name=N'Brands', @level2type=N'COLUMN',@level2name=N'IsActive' GO /****** Object: ForeignKey [FK_Brands_FilePaths_BrandLogoImageFilePath] Script Date: 03/27/2009 09:29:25 ******/ ALTER TABLE [Product].[Brands] WITH CHECK ADD CONSTRAINT [FK_Brands_FilePaths_BrandLogoImageFilePath] FOREIGN KEY([BrandLogoImageFilePath]) REFERENCES [Product].[FilePaths] ([FilePathID]) GO ALTER TABLE [Product].[Brands] CHECK CONSTRAINT [FK_Brands_FilePaths_BrandLogoImageFilePath] GO /****** Object: ForeignKey [FK_Brands_FilePaths_LargeImageFilePath] Script Date: 03/27/2009 09:29:25 ******/ ALTER TABLE [Product].[Brands] WITH CHECK ADD CONSTRAINT [FK_Brands_FilePaths_LargeImageFilePath] FOREIGN KEY([LargeImageFilePath]) REFERENCES [Product].[FilePaths] ([FilePathID]) GO ALTER TABLE [Product].[Brands] CHECK CONSTRAINT [FK_Brands_FilePaths_LargeImageFilePath] GO /****** Object: ForeignKey [FK_BrandsArticles_Articles] Script Date: 03/27/2009 09:29:25 ******/ ALTER TABLE [Product].[BrandsArticles] WITH CHECK ADD CONSTRAINT [FK_BrandsArticles_Articles] FOREIGN KEY([ArticleID]) REFERENCES [Product].[Articles] ([ArticleID]) GO ALTER TABLE [Product].[BrandsArticles] CHECK CONSTRAINT [FK_BrandsArticles_Articles] GO /****** Object: ForeignKey [FK_BrandsArticles_Brands] Script Date: 03/27/2009 09:29:25 ******/ ALTER TABLE [Product].[BrandsArticles] WITH CHECK ADD CONSTRAINT [FK_BrandsArticles_Brands] FOREIGN KEY([BrandID]) REFERENCES [Product].[Brands] ([BrandID]) GO ALTER TABLE [Product].[BrandsArticles] CHECK CONSTRAINT [FK_BrandsArticles_Brands] GO My Question is: When I am creating the typed dataset (.xsd file in app_code folder) with table adapters through VS2005, do I need to create seperate tableadapters with all getcommands along with insert, update & delete statements even for connecting table like BrandsArticle? Obviously I have many many other inter related tables like categories, products, features, colors, photos, measurements and so on. If I get clear picture about above I can create appropriate adapters for use. Please advice.Thanks.
  • 11 years ago
    I got it. Now it is working. The mistake was, I removed the unwanted(?) columns in SQL query level itself when I was creating a parametrized filter method in table adapter. I rectified the mistake by getting all the columns but with parametrized filter query for that table adapter and in formview / gridview I removed the unwanted columns. Anyway thanks.

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“The trouble with programmers is that you can never tell what a programmer is doing until it's too late.” - Seymour Cray