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 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
回复 wd990371441 :在设置adodc控件的Recordsource之前要设定它的connectionstring,貌似你是放在后边了。另外你放出文件没有frm文件,vbp文件就是个空架子,实质性的东西都在frm文件里呢!
2014年10月13日 04点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
![[汗]](/static/emoticons/u6c57.png)
百度居然把单引号换成*了
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分