我尝试将路径名插入 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'"