Posts

Showing posts with the label Sql Server

Donate

Recursive CTE Not Getting Top Level Superseded Parts In T-SQL

Image
Hello, I've been given a task to get the superseded partnumber of a certain part. The scenario is, the chain of the superseded is undetermined and could go as has high as four or more levels. See screenshot below of an example of product supersession. It illustrates that the part supersession of part M03971 is M32887 instead of its direct parent M04880. Trying out the concept of recursive CTE gets only the lowest level instead without it's parent part supersessions. WITH SupersededBy_Cte AS ( SELECT [StdDescID], [PartNumber], [SupersededBY], 0 AS [ level ] FROM [tblStdDesc] std1 WHERE std1.SupersededBY IS NULL UNION All SELECT std2.[StdDescID], std2.[PartNumber], std2.[SupersededBY], cte.[ level ] + 1 FROM SupersededBy_Cte cte INNER JOIN [tblStdDesc] std2 ON std2.SupersededBY = cte.StdDescID ) SELECT cte.[StdDescID], cte.[PartNumber], cte.[SupersededBY], cte.[ level ] FROM SupersededBy_Cte cte WH...

The EXECUTE Permission Was Denied On The Object - SQL Server Function

Image
Good day! I just recently restored a new database from the server and ran a script to create a T-SQL function. But when I called that function in C#.NET, it won't allow me to but instead returns a "The EXECUTE Permission Was Denied On The Object" error. To fix this issue, expand the database as to where the function was setup. Then click on the Security node -> Schemas -> dbo. When the Schema dialog opens, add the user name and set it's check the Grant checkbox of the Execute permission. After that, I can now successfully call the function from my .NET application. Cheers!

Windows Forms CRUD (Create/Update/Delete) Application In .NET Core And C#

Image
Hello, Here's a simple tutorial on how to create a CRUD (Create/Update/Delete) application using Windows Forms In .NET Core. The same concept is applied to a Windows Forms application in .NET Framework. First is to create a Students table on your SQL Server Database using the script below. USE [TestDatabase] GO /****** Object: Table [dbo].[Students] Script Date: 03/31/2014 14:11:36 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO SET ANSI_PADDING ON GO CREATE TABLE [dbo].[Students]( [ID] [int] IDENTITY (1,1) NOT NULL , [Name] [varchar](50) NULL , [Age] [int] NULL , [Address] [varchar](50) NULL , [Contact] [varchar](50) NULL , CONSTRAINT [PK_Students] PRIMARY KEY CLUSTERED ( [ID] 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 Create a Windows Forms App called "CRUDApplicationWi...

Getting Started With Bootstrap-Table In An ASP.NET Core MVC 5 Web Application With Entity Framework Core And SQL Server

Image
Hello, In this tutorial, I will demonstrate on how to integrate Bootstrap-Table created by Wenzhixin in an ASP.NET Core MVC 5 with Entity Framework Core and SQL Server. For this post, I'll be using Microsoft's free database called ContosoRetailDW. Most of the ASP.NET MVC 5 web project in our company use this widget for showing records to clients because this has tons of features like exporting, paging, searching, sorting by column names and a whole lot more and this awesome widget has been constantly improved by the product owner and some dedicated developers. Project Setup 1. Lets start by creating an ASP.NET Core MVC application targeting the latest framework which is .NET 5 using Visual Studio 2019. 2. Add these NuGet packages for Entity Framework Core and ASP.NET Core MVC Newtonsoft.Json 3. Next is to reverse engineer the ContosoRetailDW so that we can use it's tables. The bootstrap-table widget will load records from DimPromotions table. Scaffold-DbContext ...

Getting Started With Unity IoC Container Dependency Injection In .NET Core Using Entity Framework Core ORM And SQL Server

Image
Hello Fellow Programmers! Visual Basic Version: Using Unity IoC Container Dependency Injection, Dapper ORM and SQL Server In Visual Basic .NET Core Or .NET 5 Application In this article, I'll demonstrate on how to incorporate the Unity IoC Container into a .NET Core Console Application using Entity Framework Core ORM and SQL Server.This will apply the constructor injection methodology of dependency injection where in dependencies are provided through a constructor. I've used this IoC Container several years ago and have not done any coding after that. So it's time to revisit this terrific tool again and create a simple application that will retrieve a single record from Microsoft's sample database called ContosoRetailsDw . Make sure the DB is installed on your machine. Once done, we may now proceed in creating the sample program by performing the steps below. Project Setup 1. Start off by creating a .NET Core Console Application targetting the latest framework wh...

Getting Started With ASP.NET Core 5.0 MVC Web Application Using Dapper ORM And SQL Server

Image
Hi All, In this tutorial, I will demonstrate on how to create an ASP.NET Core 5.0 MVC CRUD Web Application using Dapper ORM which is considered as the King of Micro ORM and an alternative to both Entity Framework and RepoDB ORM. I have published ASP.NET MVC and ASP.NET Webforms articles before using Dapper ORM in this blog and have used this ORM in an internal application before. With the birth of .NET Core framework, it's time to join the bandwagon of promoting these type of tools that helped maximize the productivity of the developers by creating articles as guide or reference. Enough with the chitchat and lets start coding. :-) I. Project Setup 1. Create a Customer table in a SQL Server database using the script below. USE [Your_Database] GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO SET ANSI_PADDING ON GO CREATE TABLE [dbo].[Customer]( [CustomerID] [numeric](18, 0) IDENTITY (1,1) NOT NULL , [CompanyName] [varchar](40) NULL , [Address] [varchar](35)...

Donate