我想在程序中显示保存在数据库里面的图片,使用了如下语句:
If Adodc1.Recordset.Fields(0).Value <> Empty Then
TSno.Text = Adodc1.Recordset.Fields(0).Value
Dim strTemp As String
Dim stm As New ADODB.Stream
strTemp = App.Path & "\temp.jpg"
If Not Adodc1.Recordset.Fields("spho") is null Then
With stm
.Type = adTypeBinary
.Open
.Write Adodc1.Recordset.Fields("spho") '该字段保存图像
.SaveToFile strTemp, adSaveCreateOverWrite
.Close
End With
Image1.Picture = LoadPicture(strTemp)
End If
Set stm = Nothing
End If
上面的程序中 If Adodc1.Recordset.Fields("spho") is Not Null Then一句用来判断该字段是否为空,不为空的话才可以做显示的工作。但是在运行的时候该字段为空还没有问题,如果为空的话就会出现类型不匹配的错误,把它改为If Adodc1.Recordset.Fields("spho").Value is Not Null Then也不行。请问要怎么样才能实现这个判断呢?
If Adodc1.Recordset.Fields(0).Value <> Empty Then
TSno.Text = Adodc1.Recordset.Fields(0).Value
Dim strTemp As String
Dim stm As New ADODB.Stream
strTemp = App.Path & "\temp.jpg"
If Not Adodc1.Recordset.Fields("spho") is null Then
With stm
.Type = adTypeBinary
.Open
.Write Adodc1.Recordset.Fields("spho") '该字段保存图像
.SaveToFile strTemp, adSaveCreateOverWrite
.Close
End With
Image1.Picture = LoadPicture(strTemp)
End If
Set stm = Nothing
End If
上面的程序中 If Adodc1.Recordset.Fields("spho") is Not Null Then一句用来判断该字段是否为空,不为空的话才可以做显示的工作。但是在运行的时候该字段为空还没有问题,如果为空的话就会出现类型不匹配的错误,把它改为If Adodc1.Recordset.Fields("spho").Value is Not Null Then也不行。请问要怎么样才能实现这个判断呢?
解决方案 »
- 会员myxmouse进来拿分!
- 如何将textbox的内容insert入SQL数据库
- 1怎样把vsflexgrid中的数据写入数据库2与vsflexgrid相关的什么东西和datalist、datacombo功能一样,强在那
- 高分求救,帮帮忙,小弟是新手……^-^ ^-^ ^-^^ -^
- 有没有关于VB6.0数据库方面好点的书?
- 关于ListBox
- 借CSDN宝地,希望版主手下留情,发布一个信息,朋友公司因业务发展,需招聘程序员y
- VB还有前途吗?
- 这里有球迷吗。现在有一个和vb没有关系的话题。呼吁大家为了中国足球,明年的第一场球不要到现场看,也表示对黑哨的抗议
- 帮帮忙,急!
- 请求帮助
- 求助关于ComboBox控件的列表项问题
这样就可以了
没有is null的用法。