如何将文件路径保存到数据库
如何将文件路径保存到Access数据库,我是这么写的if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
string path = openFileDialog1.FileName;
FileInfo f = new FileInfo(path);
AddFile(f.FullName);
string strFile = Convert.ToString(numOfMusic);
string sqlString = @"Insert into
- ([filename]) values(";
sqlString += "'" + path + ")";
OleDbConnection conn = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0; Data Source=player.mdb");
OleDbCommand comm = new OleDbCommand(sqlString, conn);
conn.Open();
try
{
comm.ExecuteNonQuery();
MessageBox.Show("插入成功!");
}
catch (Exception ex)
{
MessageBox.Show("插入出错!错误原因为:\n" + ex.Message + "\n");
}
conn.Close();
}
显示 字符串的语法错误 在查找表达式“C:\a.txt)'中,怎么改啊???