1.
Dim conn As New ADODB.Connection
Dim strConn As String
Dim sql As String
'连接串
strConn = "Provider=microsoft.jet.oledb.4.0;Data Source=" & _
Server.MapPath("Data\users.mdb")
'SQL查询语句
sql = "select PhoneNumber from users where UserName like '" & _
Me.txtUserName.Text.ToString & "'"
'与数据库建立连接
conn.ConnectionString = strConn
conn.Open()
'执行SQL查询,并将结果保存在Recordset对象中
Dim rs As New ADODB.Recordset
rs.ActiveConnection = conn
rs = conn.Execute(sql)
'使用查询结果
While Not rs.EOF
If rs("PhoneNumber").Value = Me.txtPhoneNumber.Text Then
Response.Write("Correct")
Else
Response.Write("Wrong")
End If
rs.MoveNext()
End While
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
'SQL查询语句
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
Else
Response.Write("Wrong")
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)