pic.Picture = Rs!photo 为什么提示类型不对!高手请指教!谢谢!

kmdina 2003-04-04 02:49:56
pic.Picture = Rs!photo 为什么提示类型不对!photo是SQL SERVER里的二进制数据!要pic是不一Image控件!
...全文
128 点赞 收藏 25
写回复
25 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
kmdina 2003-04-04
FindResult.moduleid.Text = moduleid2 """在执行到这句时load就发生了!""要怎么才能他在
FindResult.Show以后在执行load里的语句呢?
FindResult.fileID.Text = Fil***
Set FindResult.pict.DataSource = rs
FindResult.pict.DataField = "photo"
FindResult.Show
回复
kmdina 2003-04-04
我在第二个窗体的load里加上SQL为
sql = "select * from ExamineePhoto where fileid=fileid.text"
我在第二个窗体中加了一个fileid.text,下面***部份
但加到load里就有一个问题!
FindResult.moduleid.Text = moduleid2 """在执行到这句时load就发生了!""
FindResult.fileID.Text = Fil***
FindResult.fullname.Text = fname
FindResult.sex.Text = sex
FindResult.ID_card.Text = IDcard
Set FindResult.pict.DataSource = rs
FindResult.pict.DataField = "photo"
FindResult.Show
回复
kmdina 2003-04-04
我的两个窗体的数据要怎么才能同步呢!
回复
Cooly 2003-04-04
If Not rst.EOF then rst.MoveNext
回复
Cooly 2003-04-04
移动记录指针
回复
Cooly 2003-04-04
对啊,你的str具体是什么啊?rs结果集中没有photo字段的内容,仔细检查一下str是否正确吧
回复
kmdina 2003-04-04
我现在把你教我的语句放到第二个窗口去了,就没有错误,但是,现在显示的图片和我查找的记录不是同一个,总是第一个!不会改变,这要怎么做呀!
回复
kmdina 2003-04-04

调试一下debug.print rs( "photo ")看看出不出错。
出的错是,实时错误'3265':
项目在所面的名称或序数中未被发现!
另外InitList在什么地方调用?str参数的值是什么?
是在显示查找结果到Listview时调用,str参数是我查找的条件语句!



回复
Cooly 2003-04-04
你在指定pict.DataSource时,rs是什么?
调试一下debug.print rs("photo")看看出不出错。

另外InitList在什么地方调用?str参数的值是什么?
回复
kmdina 2003-04-04


Private Sub Form_Load()
Set rs = New ADODB.Recordset
Set adoCn = New ADODB.Connection

strCn = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security" & _
"Info=False;Initial Catalog=kaodian;Data Source=ASP\ASP"
adoCn.Open strCn
'sql = "SELECT Fileinfo.fileID,Fileinfo.fullname,Fileinfo.ID_card,Fileinfo.sex," & _
' "SignInfo.examineeId,SignInfo.ModuleID," & _
' "result_info.Exam_Score into newi " & _
' "from Fileinfo,SignInfo,result_info" & _
' " where fileinfo.FileID = SignInfo.FileID and SignInfo.examineeID " & _
' "= result_info.examineeID "
' Rs.Open sql, adoCn, adOpenKeyset, adLockOptimistic
sql = "select * from ExamineePhoto"
' sql = "select * from fileinfo,ExamineePhoto where ExamineePhoto.fileid=Fileinfo.fileID"
rs.Open sql, adoCn, adOpenKeyset, adLockOptimistic
'添加 ColumnHeaders。
Listinfo.ColumnHeaders.Add , , "序号", 600, lvwColumnLeft
Listinfo.ColumnHeaders.Add , , "姓名", 900, lvwColumnCenter
Listinfo.ColumnHeaders.Add , , "性别", 600, lvwColumnCenter
Listinfo.ColumnHeaders.Add , , "身份证号", 2150, lvwColumnCenter
Listinfo.ColumnHeaders.Add , , "通过模块", 1380, lvwColumnCenter
Listinfo.ColumnHeaders.Add , , "分数", 680, lvwColumnCenter
Listinfo.ColumnHeaders.Add , , "", 0, lvwColumnCenter

cboOper1.AddItem "大于"
cboOper1.AddItem "小于"
cboOper1.AddItem "等于"
cboOper1.Text = cboOper1.List(0)

cboOper1.Enabled = False
fileID.Enabled = False
fullname.Enabled = False
ID_card.Enabled = False
Exam_Score.Enabled = False

cboOper1.BackColor = &H8000000F
fileID.BackColor = &H8000000F
fullname.BackColor = &H8000000F
ID_card.BackColor = &H8000000F
Exam_Score.BackColor = &H8000000F


End Sub
Public Sub InitList(ByVal Str As String) ' 'listview显示赋值函数
Dim Num As Integer
Dim itmx As ListItem

If rs.State = adStateOpen Then rs.Close
Set rs = New ADODB.Recordset

rs.Open Str, adoCn, adOpenDynamic, adLockOptimistic, adCmdText

Num = 1
Listinfo.ListItems.Clear '添加新值之前先清除一下列表内容
While Not rs.EOF
Set itmx = Listinfo.ListItems. _
Add(, , Num)
Num = Num + 1
itmx.SubItems(1) = rs!fullname
itmx.SubItems(2) = rs!sex
itmx.SubItems(3) = rs!ID_card
itmx.SubItems(4) = rs!modelname
itmx.SubItems(5) = rs!Exam_Score


rs.MoveNext
Wend
End Sub

Private Sub Listinfo_dblClick()
display (Listinfo.SelectedItem.Index)
Dim ind As Integer
Dim itmx1 As ListItem
Dim ID2 As Variant
Dim moduleid1 As String
Dim moduleid2 As String

Set itmx1 = Listinfo.ListItems.Item(Listinfo.SelectedItem.Index + 1)
ind = Listinfo.SelectedItem.Index + 1
ID2 = itmx1.SubItems(3)
moduleid1 = itmx1.SubItems(4)
If ID = ID2 Then
moduleid2 = moduleid & "、" & moduleid1
Set itmx1 = Listinfo.ListItems.Item(ind + 1)
ind = ind + 1
ID2 = itmx1.SubItems(3)
moduleid1 = itmx1.SubItems(4)
If ID = ID2 Then
moduleid2 = moduleid2 & "、" & moduleid1
Set itmx1 = Listinfo.ListItems.Item(ind + 1)
ind = ind + 1
ID2 = itmx1.SubItems(3)
moduleid1 = itmx1.SubItems(4)
If ID = ID2 Then
moduleid2 = moduleid2 & "、" & moduleid1
Set itmx1 = Listinfo.ListItems.Item(ind + 1)
ind = ind + 1
ID2 = itmx1.SubItems(3)
moduleid1 = itmx1.SubItems(4)
If ID = ID2 Then
moduleid2 = moduleid2 & "、" & moduleid1
End If
End If
End If
Else: moduleid2 = moduleid
End If

FindResult.moduleid.Text = moduleid2
FindResult.fileID.Text = Fil
FindResult.fullname.Text = fname
FindResult.sex.Text = sex
FindResult.ID_card.Text = IDcard
Set FindResult.pict.DataSource = rs
FindResult.pict.DataField = "photo"
FindResult.Show

End Sub
Public Function display(ind As Integer) 'listview显示值函数
Dim itmx As ListItem
Set itmx = Listinfo.ListItems.Item(ind)
Fil = itmx.SubItems(6)
fname = itmx.SubItems(1)
sex = itmx.SubItems(2)
IDcard = itmx.SubItems(3)
ID = itmx.SubItems(3)
moduleid = itmx.SubItems(4)
End Function
回复
kmdina 2003-04-04
请帮我看看为什么会在 FindResult.pict.DataField = "photo"这里停下来报错!
实时错误'545'
报了一个错,不能绑定到字段或数据成员:'photo'
回复
kmdina 2003-04-04
还是一样的错!
回复
lxcc 2003-04-04
up
回复
kmdina 2003-04-04
我的有别的东西,我是从一个Listview里单击后在执行你的这个语句就会出错,要不我把代码发给你,你帮我看看,可以吗?
回复
Cooly 2003-04-04
怎么会报错啊?

你把Connection和Recordset对象定义为全局变量就可以在整个工程中使用了。
回复
kmdina 2003-04-04
实时错误'545'
报了一个错,不能绑定到字段或数据成员:'photo'
回复
kmdina 2003-04-04
对了!出来了!但我还有问题!我用的是从一个窗体查出的结果显示到第二个窗体上去!
回复
cbr7619 2003-04-04
C:\temp\Picturetemp
Cooly(☆回答问题不要分儿☆) 的很好
回复
kmdina 2003-04-04
我发消息给你了!
回复
Cooly 2003-04-04
我只是做了个例子

set picture1.datasource=rs
picture1.datafield="photo"

其中:
picture1是Picture控件
rs是Adodb.Recordset对象
photo是image类型的字段名
回复
加载更多回复
相关推荐
发帖

1187

社区成员

VB 数据库(包含打印,安装,报表)
申请成为版主
帖子事件
创建了帖子
2003-04-04 02:49
社区公告
暂无公告