Private Sub Command1_Click() Adodc1.ConnectionString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=student;Data Source=localhost" Adodc1.RecordSource = "select * from stud_grade where STUD_ID='" & Text1.Text & "'" Adodc1.Refresh If Adodc1.Recordset.RecordCount > 0 Then MsgBox "你输入的学号在数据库中" Else MsgBox "你输入的数据不在数据库中" End If End Sub
比如说ADO,SQL语法等等,你需要一点点学
直接给你代码没任何意义
Adodc1.ConnectionString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=student;Data Source=localhost"
Adodc1.RecordSource = "select * from stud_grade where STUD_ID='" & Text1.Text & "'"
Adodc1.Refresh
If Adodc1.Recordset.RecordCount > 0 Then
MsgBox "你输入的学号在数据库中"
Else
MsgBox "你输入的数据不在数据库中"
End If
End Sub