MySqlConnection conn = new MySql.Data.MySqlClient.MySqlConnection(); MySqlCommand cmd = new MySql.Data.MySqlClient.MySqlCommand(); string SQL; conn.ConnectionString = "server=localhost; userid=root;password=;database=test;"; conn.Open(); try { string[] files = Directory.GetFiles(@"E:\voices\", "*.wav"); foreach (string file in files) { string filename = Path.GetFileName(file); string directory = Path.GetFullPath(file); cmd.Parameters.AddWithValue("@dwnfile_name", filename); cmd.Parameters.AddWithValue("@dwnfile_path", directory); SQL = "insert into sdwn_files(dwnfile_id,dwnfile_name,dwnfile_path) values(NULL, @dwnfile_name, @dwnfile_path)"; cmd.Connection = conn; cmd.CommandText = SQL; cmd.ExecuteNonQuery(); MessageBox.Show("Files Inserted into database successfully!", "Success!", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } conn.Close(); } catch (MySql.Data.MySqlClient.MySqlException ex) { MessageBox.Show("Error " + ex.Number + " has occurred: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
foreach
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)