请问在C#里怎么把BMP图片存到access的OLE对象字段中?怎么写SQL语句啊。我是下面做的有问题:
FileStream fs = new FileStream(m_filename, FileMode.Open);
Byte[] FileByteArray = new Byte[fs.Length];
fs.Read(FileByteArray,0,(int)fs.Length);
fs.Close();
然后根据sql="INSERT INTO Data_Employee Img="+"'"+FileByteArray+"'";

解决方案 »

  1.   

    // comm为OleDbCommand的实例。
    comm.CommandText = "INSERT INTO Data_Employee Img VALUES (@Img)";comm.Parameters.Add("@Img", OleDbType.Binary);
    comm.Parameters["@Img"].Value = FileByteArray;// conn为OleDbConnection的实例。
    conn.Open();
    comm.ExecuteNonQuery();
    conn.Close();
      

  2.   

    System.IO.FileInfo fi=new System.IO.FileInfo(openFileDialog1.FileName);
    int imglen=(int)fi.Length;

    clzhaopian=new byte[imglen];
    System.IO.Stream imgdatstream=fi.OpenRead();
    int n=imgdatstream.Read(clzhaopian,0,imglen);
    ei=cs.InsertCarEnrol(clzhaopian);