C#.Net program to drop a table from the MySql database dynamically
All Answers
total answers (1)
Severity: 8192
Message: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated
Filename: libraries/Filtered_db.php
Line Number: 23
total answers (1)
Program:
The source code to drop a table from the MySql database dynamically is given below. The given program is compiled and executed successfully.
Output:
Explanation:
In the above program, we imported a namespace MySql.Data.MySqlClient to establish the connection with the MySql database. Then we created a class Program that contains a Main() method.
The Main() method is the entry point for the program. In the Main() method, we created a connection string variable ConnString that contains the database connectivity credentials. After that we established the connection to the MySql database using MySqlConnection class and then drop the "employee" table in the database using ExecuteNonQuery() method of MySqlCommand class and print the "Table employee dropped successfully" message on the console screen.