我想把图象插入ACESS数据库中,在数据库中设置了三个字段,其中image是OLE类型,插入时报错,错误提示是INSERT into 语句的语法错误....但是如果我不插入图象,只插入StudentID, Name字符串类型有没有错误,期待大家回复.
   byte[]image_bytes =null;
   OpenFileDialog myDialog = new OpenFileDialog();
   myDialog.ShowDialog();
   if(myDialog.FileName.Trim()!="")
   {
    pictureBox1.Image = System.Drawing.Bitmap.FromFile(myDialog.FileName);
   }
   
       Stream mystream = myDialog.OpenFile();
      leng =(int)mystream.Length;
             image_bytes = new byte[leng];
       mystream.Read(image_bytes,0,leng);
    mystream.Close();
string CString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " + Application.StartupPath + @"\S11.MDB";
   MyCon=new OleDbConnection(CString);
   try//创建连接对象
   {
    MyCon.Open();//打开连接}
   }
   catch(Exception ee)
   {
    MessageBox.Show(ee.Message);
   
   }  
   try
   {
    string  SqlCmd = "INSERT INTO st(StudentID, Name, image) VALUES (@StudentID, @Name, @image)";
       MyCom = new OleDbCommand(SqlCmd,MyCon);
    MyCom.Parameters.Add("@StudentID", OleDbType.VarChar,8).Value = "11010187";
    MyCom.Parameters.Add("@Name", OleDbType.VarChar,8).Value = "杜威";
       MyCom.Parameters.Add("@image",OleDbType.Binary,leng).Value = image_bytes;
        MyCom.ExecuteNonQuery();
    MessageBox.Show("成功");
   } 
   catch(Exception ee)
   {
   
    MessageBox.Show(ee.Message);
   }



 
											





 
	    

 
	




