Skip to Content
Beginning Database Design Solutions, 2nd Edition
book

Beginning Database Design Solutions, 2nd Edition

by Rod Stephens
April 2023
Beginner
736 pages
19h 23m
English
Wiley
Content preview from Beginning Database Design Solutions, 2nd Edition

17MariaDB in C#

This example demonstrates the MariaDB database in a C# application. If you skipped Chapter 16, “MariaDB in Python,” which built a similar example in Python, go to that chapter and read the beginning and the first two sections, which are described in the following list:

  • “Install MariaDB” explains how to install MariaDB.
  • “Run HeidiSQL” explains how to use the HeidiSQL database management tool to create a MariaDB database.

When you reach the section “Create the Program” in Chapter 16, return to this chapter and read the following sections.

CREATE THE PROGRAM

To create a C# program to work with the MariaDB extraterrestrial animals database, create a new C# Console App (.NET Framework) and then add the code described in the following sections.

Jupyter Notebook lets you execute cells individually, but C# won't let you do that. It will, however, let you group related code into methods, so that's what we'll do here.

Add code to the main method so that it looks like the following:

using MySqlConnector;

static void Main(string[] args)
{
    CreateDatabase();
    // CreateTables();
    // CreateData();
    // FetchData();
 
    Console.ReadLine();
}

Initially, the main method only calls CreateDatabase (described shortly) and then waits for the user to press Enter. You'll uncomment the other statements as you work through the following sections, which explain how the other methods work.

Install MySqlConnector

To install a database connector, open the Project menu and select Manage ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Beginning Database Design Solutions

Beginning Database Design Solutions

Rod Stephens
Grokking Relational Database Design

Grokking Relational Database Design

Michail Tsikerdekis, Qiang Hao

Publisher Resources

ISBN: 9781394155729Purchase Link