About the C# CAS Basic Example

C# Code Access Security & Security Action

The Security Zone describes the location in which the application is running. Say; for example, a dot-net application that runs through the internet is seen as Internet Zone application. So based on the locations, Dotnet determines the zones and claims a set of securities on it.

This example will help us learn about the Code Access Security and how to apply it to an assembly. The buttons marked as 1 and 2 are used to read the system environment variables called SecTest and UserName. Here, UserName is a built-in environment variable and SecTest is the one we create for checking the Code Access Security. The text box marked as 3 is to display the value to read from  the system Env. variable.

Multi-line table valued function example

SQL Table-Valued Function Example

In the past article we saw creating a simple scalar-valued function. Now, here in this article, we will look at building the Table-Valued function. Unlike the scalar-valued function a table-valued function returns a table to the caller. There are two kinds of table-valued functions we can write. Those are:

In-Line Table-Valued functions
Multi-line table valued functions

In this Example, we learn how to create both the functions. OK, let us start.

SQL Scalar-Valued function with Parameter

SQL Scalar-Valued Function Explained

Stored Procedure and function in SQL server are the compiled unit of SQL Program which performs a specific task. Unlike a stored procedure, a User-Defined Function in SQL server can take part in the SQL Select Queries. In this example, we will try to create and use the Scalar-Valued Function in the SQL Server. A Scalar-Valued function returns a single value to its caller.

We create the Examples in this article using Microsoft supplied Titles table of Pubs database. You can download the SQL Script that creates the Pubs and NorthWnd database from the SQL 2005 Section of this site. Before we begin, here is the content of the Titles table that we can refer while going through the article:

MFC View-Port Origin and Window Origin

MFC Mapping Modes & Drawing Coordinate

MFC supports two kinds of coordinate systems. One is Device Coordinate and the other one is Logical Coordinate. In device coordinate, we point out all in terms of pixels. In logical coordinate, we measure each unit in terms of Metric Standard or British Standard. How each unit maps to the logical measure is called the mapping. We can mention the mapping using the Mapping Modes. In MFC, having the knowledge of Drawing Origin is the key to draw in the Client Area the way you want.

In this Example, we will walk through the examples and demo videos, which will help us in learning the Mapping Modes and doing the MFC drawing using the device contexts. We will also try the ViewPort Origin and Window Origin and how to use them while drawing using MFC GDI APIs.

Example Application Screenshot

Get Table Schema Information Using Ado.Net

The item marked as 1 is a multi-line text-box control used to show the table schema shown in section 1 of this example. The Get Table Schema button (Marked as 2) displays the schema data of the discount table in the multi-line text box. Before using this example, one need to setup the connection string to the Pubs database. Setting the connection string for the NorthWnd database is shown in the below video. We can follow the same method to set the connection string for the Pubs database as the table DISCOUNTS resides in it. When you create Connection String name it as PUBSDB.