Recordset 对象必须支持更新 update 方法 不行就用 UpdateBatch 方法
解决方案 »
- 还有问题大家一起帮忙看看
- 太神奇了!!!抓图代码只要两行!!!!!!!!!!!!!!!!!!!
- 100分求救,如何使用用友的数据库ufdata.mdf中的Gl_accvouch查询生成各个月份的资产负债表 求救
- 请教使用MSFlexGrid控件实现双行标题
- 如何判断进程中已经运行了excel.exe?
- 请问statusbar的pannel中所显示的字体能否设置字体的颜色?急~~~~~~
- 关于控件
- 情人节
- 如何在一个ACCESS表里 的一个字段(该字段为日期型)里 取相邻2个记录的 值的差 该怎样编写代码 谢谢了 很急
- 打牌的程序!!
- 关于字符串的问题
- 不好意思,又来了,还是vb+sql server!
Public Sub save_Doc()On Error GoTo ErrHandleDim cnn As New ADODB.Connection
Dim rst As New ADODB.Recordset
Dim bit() As Byte
Dim varPath As String '文档的路径
Dim sSql As String
Dim lngFileName As Integer lngFileName = FreeFile()
varPath = App.Path & "\Hg_Jckfxwz\" & txtWzxh.Text & ".doc"
cnn.Open ConnStr sSql = "SELECT * FROM " & tabName & " WHERE Wzxh = " & txtWzxh.Text
'选出要增加或修改文档的记录 rst.Open sSql, cnn, adOpenKeyset, adLockOptimistic If Not (rst.EOF And rst.BOF) Then
If varPath = "" Then
' 然后将字节数组的内容写入数据库即可
rst.Fields("Wznr1") = ""
rst.Update
Else
Open varPath For Binary As lngFileName
ReDim bit(LOF(lngFileName)) As Byte
Get lngFileName, 1, bit()
' 然后将字节数组的内容写入数据库即可 rst.Fields("Wznr1").AppendChunk (bit())
rst.Update
MsgBox "Save to database success.", vbOKOnly + vbInformation, "保存成功"
Close lngFileName
End If
rst.Close
cnn.Close
End If
Exit Sub
ErrHandle:
MsgBox "错误(" & Err.Number & ") : " & Err.Description & vbCrLf & "Save to database failure!", vbOKOnly + vbCritical, "保存失败"
If rst.State = adStateOpen Or rst.State = adStateOpen + adStateExecuting Or rst.State = adStateOpen + adStateFetching Then
rst.Close
End If
If cnn.State = adStateOpen Then
cnn.Close
End If
Close lngFileName
Exit Sub
End Sub执行完后,数据库中却没有值。什么原因呢?