一直错,求助
vb吧
全部回复
仅看楼主
level 2
1.要实现的功能是
输入编号,点查询按钮,下图出现结果
2、但是每次都出现
点调试后
2014年10月12日 08点10分 1
level 2
@sunshinebean
吧主,你会吗,求助啊
2014年10月12日 08点10分 2
level 2
2014年10月12日 08点10分 3
level 9
datPriamryRS 是什么?估计是Adodc1.RecordSource未赋值,或者Adodc控件名不是Adodc1
2014年10月12日 10点10分 4
datPriamryRS是Adodc控件的名称
2014年10月13日 04点10分
回复 wd990371441 :那怎么后面又用Adodc1了?目测你只添加了一个Adodc控件呀。
2014年10月13日 04点10分
回复 youbest2013 :@youbest2013没变蓝,在8楼
2014年10月13日 04点10分
level 11
所有文件大不大?不大的话打包发到网盘 贴地址过来
2014年10月12日 15点10分 5
level 9
Adodc控件名称不对
2014年10月12日 15点10分 6
名称也有影响吗,我全部用的是这个名称啊
2014年10月13日 04点10分
level 2
@ youbest2013
改正了,如下
Private Sub Command1_Click()
Dim strClass As String
strClass = Text1.Text
If strClass = "" Then
MsgBox "编号不能为空!"
Else
datPrimaryRS.RecordSource = "select * from 基本信息 where 编号 = " & strClass
datPrimaryRS.Refresh
If datPrimaryRS.Recordset.EOF Then MsgBox "找不到您所用的信息,您输入的员工编号不存在!"
End If
End Sub
2014年10月13日 04点10分 8
2014年10月13日 04点10分
回复 wd990371441 :在设置adodc控件的Recordsource之前要设定它的connectionstring,貌似你是放在后边了。另外你放出文件没有frm文件,vbp文件就是个空架子,实质性的东西都在frm文件里呢!
2014年10月13日 04点10分
回复 youbest2013 :不好意思,我重新发一下 http://yunpan.cn/cgzSaW5LW9SIv 访问密码 73fd
2014年10月13日 05点10分
level 8
Private Sub Command1_Click()
Dim strClass As String
strClass = Text1.Text
If strClass = "" Then
MsgBox "编号不能为空!"
Else
datPrimaryRS.CommandType = adCmdText
datPrimaryRS.RecordSource = "select * from 基本信息 where 编号 = *" & strClass & "*"
datPrimaryRS.Refresh
If datPrimaryRS.Recordset.EOF Then MsgBox "找不到您所用的信息,您输入的员工编号不存在!"
End If
End Sub
2014年10月13日 08点10分 10
level 9
sorry,上课去了,看了一下,你主要有两个错误:1.datPrimary.commandtype应设为unknown,2.Sql语法错误,strclass是字符串,两边应加引号。另外,发现移到最后记录的时候后自动添加记录,不知你是否需要,不过按我理解是不应该的,你下面有一个添加按钮了。所以把EofAction设为0.
以下是查询按钮的更正
Private Sub Command1_Click()
Dim strClass As String
strClass = Text1.Text
If strClass = "" Then
MsgBox "编号不能为空!"
Else
datPrimaryRS.CommandType = adCmdUnknown
datPrimaryRS.RecordSource = "select * from 基本信息 where 编号 =
*" & strClass & "*"
datPrimaryRS.Refresh
If datPrimaryRS.Recordset.EOF Then MsgBox "找不到您所用的信息,您输入的员工编号不存在!"
End If
End Sub
2014年10月13日 08点10分 11
[汗] 百度居然把单引号换成*了
2014年10月13日 10点10分
level 11
Private Sub Command1_Click()
Dim strClass As String
strClass = Text1.Text
If strClass = "" Then
MsgBox "编号不能为空!"
Else
datPrimaryRS.CommandType = adCmdUnknown
datPrimaryRS.RecordSource = "select * from 基本信息 where 编号 =*" & strClass & "*"
datPrimaryRS.Refresh
If datPrimaryRS.Recordset.EOF Then MsgBox "找不到您所用的信息,您输入的员工编号不存在!"
End If
End Sub
2014年10月13日 10点10分 12
原来是百度的问题 我说怎么都发的是*号 不是单引号
2014年10月13日 10点10分
回复 vb2070 :是呀,这作死的百度,这么久了竟然还没解决这个问题。
2014年10月13日 11点10分
level 11
‘’**
**
2014年10月13日 10点10分 13
level 2
不好意思,一直忙其他事,没有及时谢谢各位大神
在此,谢谢给位大神的无私帮助,小弟受益匪浅,谢谢
@youbest2013
@vb2070
@网海1书生
@lz98ds2
2014年10月19日 14点10分 14
1