C#.Net program to create a table in MySql database dynamically

Hey reader! Do you know one thing? Using this article, you can easily C#.Net program to create a table in MySql database dynamically.

C#.Net program to create a table in MySql database dynamically

C#.Net program to create a table in MySql database dynamically

//C#.NET program to create a table in MySql 
//database dynamically.

using MySql.Data.MySqlClient;
using System;

class Program
{
    static void Main(string[] args)
    {
        //Connection String to connect with MySQL database.
        string connString = "server=localhost;userid=root;password=root;database=Sample_DB";
        MySqlConnection conn = new MySqlConnection(connString);

        conn.Open();

        MySqlCommand cmd = new MySqlCommand("create table employee (eid int, ename varchar(16), salary int) ", conn);
        cmd.ExecuteNonQuery();

        Console.WriteLine("Table employee created successfully");
        conn.Close();
    }
}
Table employee created successfully
Press any key to continue . . .

Final Words

We are confident that you will understand the C#.Net program to create a table in MySql database dynamically article. Also if you have any information regarding this article please let us know in the comment box way comment.

Hi, I'm Ranjith a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Deekshi. Here, I post about programming to help developers.

Share on:

Leave a Comment