vb标准表达式中数据类型不匹配如何解决
DimadocnAsNewADODB.ConnectionPrivateSubCommand1_Click()IfText1.Text=""ThenElseDimrsAs...
Dim adocn As New ADODB.Connection
Private Sub Command1_Click()
If Text1.Text = "" Then
Else
Dim rs As New ADODB.Recordset
Dim strSql As String
strSql = "select * from 员工 where 工号=" & Trim(Text1.Text)
adocn.Open
rs.Open strSql, adocn, 2, 2
If rs.EOF And rs.BOF Then '查询没有此工号
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
'Text5.Text = ""
' Text6.Text = ""
' Set rs = Nothing
adocn.Close
MsgBox "没有查询到符合您要求的信息!", vbCritical + vbOKOnly, "信息"
Exit Sub
Else
Text2.Text = rs.Fields("姓名")
Text3.Text = rs.Fields("性别")
Text4.Text = rs.Fields("学历")
' Text5.Text = rs.Fields("出生年月")
' Text6.Text = rs.Fields("身份证")
Set rs = Nothing
adocn.Close
End If
End If
End Sub
Private Sub Form_Load()
adocn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\db\DB1.mdb;Persist Security Info=False"
End Sub 展开
Private Sub Command1_Click()
If Text1.Text = "" Then
Else
Dim rs As New ADODB.Recordset
Dim strSql As String
strSql = "select * from 员工 where 工号=" & Trim(Text1.Text)
adocn.Open
rs.Open strSql, adocn, 2, 2
If rs.EOF And rs.BOF Then '查询没有此工号
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
'Text5.Text = ""
' Text6.Text = ""
' Set rs = Nothing
adocn.Close
MsgBox "没有查询到符合您要求的信息!", vbCritical + vbOKOnly, "信息"
Exit Sub
Else
Text2.Text = rs.Fields("姓名")
Text3.Text = rs.Fields("性别")
Text4.Text = rs.Fields("学历")
' Text5.Text = rs.Fields("出生年月")
' Text6.Text = rs.Fields("身份证")
Set rs = Nothing
adocn.Close
End If
End If
End Sub
Private Sub Form_Load()
adocn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\db\DB1.mdb;Persist Security Info=False"
End Sub 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询