如题,我仿照坛子里的类似帖子写了以下代码:
If CommonDialog1.FileName <> "" Then
Set StmPic = New ADODB.Stream
StmPic.Type = adTypeBinary
StmPic.Open
StmPic.LoadFromFile (CommonDialog1.FileName)
cn.Open strCN
cn.Execute "insert into incoming_issue(issue_date,piece_part,part_no,vendor,vendor_lot,pkg,pkg_code,assylot_no,assylot_qty,defect_qty,iqc_date,cqi_no,disposal,defect_rate,disc,pic)values('" & dtpDate.Value & "','" & cboPiece_Part.Text & "','" & txtPart_No.Text & "','" & txtVendor.Text & "','" & txtVendor_Lot.Text & "','" & cboPKG.Text & "','" & cboCode.Text & "','" & txtLot.Text & "','" & txtInput_Qty.Text & "','" & txtDef_Qty.Text & "','" & txtIQC_Date.Text & "','" & txtCQI_No.Text & "','" & txtDisposal.Text & "','" & lblRate.Caption & "','" & txtDisc.Text & "','" & StmPic.Read & "')"
cn.Close
CommonDialog1.FileName = "" '清空是防止重复按Save鍵,造成重复保存图像
End If错误代码如下:
[Microsoft][ODBC Microsoft Access Driver]Syntax error in string in query expression
我想把图片写入PIC中,PIC已经设置为OLE。
另外求教,如何用sql语句更新我数据库中的ole图片,以及如何用SQL语句将数据库中的ole图片读取到IMAGE控件中?

解决方案 »

  1.   

    从数据库读到二进制数组:
    bteContent是一个二进制数组。bteContent = objAdoRecS.Fields("imageFile").GetChunk(objAdoRecS.Fields("imageFile").ActualSize)从二进制数组写入数据库:objAdoRecS.Fields("imageFile").AppendChunk bteContent
      

  2.   

    如何使用 ADO Stream 对象访问和修改 SQL Server BLOB 数据
    http://support.microsoft.com/default.aspx?scid=kb;zh-cn;258038把Access的OLE字段当做SQLServer BLOB类型即可!
      

  3.   

    我只想知道应该如何修改我的SQL语句,二位的说法对我来说没有用
      

  4.   

    '" & StmPic.Read & "')"
    //这样会把Stream当做字符串应该INSERT后用UPDATE更新该字段,用可以用ADODB.Command的Parameters,或者就用rs.Update的方法更新
      

  5.   

    对于保存图形的字段
    无法用SQL语句进行编辑
    你可以参照上面两位的建议
    用stream进行更新