Skip to main content
CSharpUniversity ASP.NET and C# lessons

The search runs entirely in your browser over the published lesson list.

Creating a database and some test rows

Every data lesson needs a database with a table and a few rows. Building one takes a minute.

Create the database and table

SQL
CREATE DATABASE Shop;

CREATE TABLE Product (
    Id int IDENTITY(1,1) PRIMARY KEY,
    Name nvarchar(100) NOT NULL,
    Price decimal(10,2) NOT NULL
);

Add a few rows

SQL
INSERT INTO Product (Name, Price) VALUES ('Hammer', 12.50);
INSERT INTO Product (Name, Price) VALUES ('Saw', 24.00);
INSERT INTO Product (Name, Price) VALUES ('Drill', 89.99);

Why the identifier matters

The identity column gives each row a unique number that the database assigns. That number is how you update and delete a single row precisely.

Test data is for testing. Use obvious, made up values so nobody mistakes them for real records later. Never put real customer data into a practice database.

Now you can read those rows in talking to a database with ADO.NET.

New lessons by email

Leave your address and get a short note whenever a fresh lesson is published. No account needed and you can stop at any time.

Thank you. Your address has been noted in this browser session. Connect a mailing service to deliver the notes for real.