=====DML(create table)=====
<pre>
public void CreateTable(string host, string database, string user, string password) { // create database jra default character set utf8using MySql.Data.MySqlClient; // create user 'jra'@'localhost' identified by 'new password'; // create user 'jra'@'%' identified by 'new password'using System.Data; // grant all privileges on *using System.* to 'jra'@'%' with grant optionDiagnostics;
var conInfo = $"Database=public void CreateTable(string host, string database, string user, string password){ // create database jradefault character set utf8;Data Source=192.168.0.2;User Id= // create user 'jra;Password='@'localhost' identified by 'new password; pooling = false; convert zero datetime=True"'; using (var conn = // create user 'jra'@'%' identified by 'new MySqlConnection(conInfo)) {password'; conn // grant all privileges on *.Open()* to 'jra'@'%' with grant option;
var conInfo = $"Database=jra;Data Source=192.168.0.2;User Id=jra;Password=password; pooling = false; convert zero datetime=True"; using (var conn = new MySqlConnection(conInfo)) { conn.Open(); var createTable = @"
create table jra_data (
rec_spec varchar(2) not null, rec_key varchar(100) not null, make_date varchar(10) not null, data_type varchar(1) not null, data mediumtext, primary key(rec_spec, rec_key)
)";
var cmd = new MySqlCommand(createTable); cmd.Connection = conn; cmd.ExecuteNonQuery(); } }
</pre>