パス名をmysqlデータベースに挿入しようとしましたが、機能していますが奇妙です。私が見つけたのは、パスが私のプロジェクトディレクトリのパスではないということです。私のプログラムを使用すると、結果は " D:musicFOREIGN!!New folderarat cakepHilary Duff - Wake Up.mp3 " になります。phpmyadmin からクエリを手動で挿入すると、その結果は " D:\music\FOREIGN!!\New folder\barat cakep\Hilary Duff - Wake Up.mp3 " になり、何もおかしくありません。私は何か間違ったことをしましたか?ここに私のコードがあります:
public static void add_song(song input)
{
establised();
try
{
MySqlCommand command = connection.CreateCommand();
command.CommandText = string.Format("INSERT INTO song (ID_SONG, ID_GENRE, ID_CATEGORY, SONG_TITLE, SONG_ARTIST, SONG_LOCATION, SONG_PLAYED) select '', b.id_genre, c.id_category, '{0}', '{1}', '{2}', '0' from genre b, category c where b.genre = '{3}' and c.category = '{4}' ", input.title, input.artist, input.location, input.genre, input.category);
command.ExecuteNonQuery();
}
catch (Exception e) { }
release();
}
これが私のクエリの例です:
"INSERT INTO song (ID_SONG, ID_GENRE, ID_CATEGORY, SONG_TITLE, SONG_ARTIST, SONG_LOCATION, SONG_PLAYED) select '', b.id_genre, c.id_category, 'Wake Up', 'Hilary Duff', 'D:\\music\\FOREIGN!!\\New folder\\barat cakep\\Hilary Duff - Wake Up.mp3', '0' from genre b, category c where b.genre = 'Pop' and c.category = 'international'"