请教给位大侠
我的问题是需要从excel中显示出与选中的文件名相应的信息显示在datagirdview中。
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Data.OleDb;namespace F1
{
    public partial class DataOperating : Form
    {
        public DataOperating()
        {
            InitializeComponent();
        }
/// <summary>
/// 浏览文件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
        private void btnCSB_Click(object sender, EventArgs e)
        {
            if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
            {
                tbMapFilePath.Text = folderBrowserDialog1.SelectedPath;
                string[] strFiles = Directory.GetFiles(tbMapFilePath.Text);
                //显示路径下文件
                Photolist.Items.Clear();
                foreach (string f in strFiles)
                {
                    //显示路径
                    Photolist.Items.Add(f);
                }
            }
        }
        /// <summary>
        /// 选择文件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Photolist_SelectedIndexChanged(object sender, EventArgs e)
        {
            //判断选择文件
            Photoview.Image = Image.FromFile(Photolist.SelectedItem.ToString());
            string nm = System.IO.Path.GetFileName(Photolist.SelectedItem.ToString());
            MessageBox.Show(nm);
            //取得父目录,连接excel文件
            try
            {
                string folderPath = new FileInfo(tbMapFilePath.Text).DirectoryName;
                string path = folderPath + "\\PHOTO填写样例.xlsx";
                //连接excel
                string strSource = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + path + ";extended properties='Excel 12.0;HDR=N0;IMEX=2;'";
                OleDbConnection conn = new OleDbConnection(strSource);
                string sqlstring = "SELECT * FROM [PHOTO1$] WHERE FILE LIKE '%" + nm + "%";
                OleDbDataAdapter adapter = new OleDbDataAdapter(sqlstring, conn);
                DataTable dt = new DataTable();
                adapter.Fill(dt);
                this.datagirdview1.DataSource = dt.DefaultView;
            }
            catch (Exception ep)
            {
                MessageBox.Show(ep.Message);
            }
        }
    }
}
可是sql老是报错。说字符串的语法错误在查询表达式'FILE LIKE '%DSCN0078.jpg%"中;