Public Function selectString(ByVal strSql As String) As String
Dim conn As SqlConnection
Dim comm As SqlCommand
Try
If strSql Is Nothing OrElse _
strSql.Trim.Equals("") Then
Return Nothing
End If
conn = New SqlConnection("") '此出写连接语句
conn.Open()
comm = New SqlCommand(strSql, conn)
Return comm.ExecuteScalar().ToString
Catch ex As Exception
Return Nothing
Finally
If Not conn Is Nothing Then
conn.Close()
End If
conn = Nothing
comm = Nothing
End Try
End Function
Private Sub ButtonOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonOK.Click
Dim strSql As String
Dim table As DataTable
Try
strSql = "select ShainPwd from tblShain where UserName =" _
& "'" & textboxUserName.Text & "'"
strSql &= "And PWD='" & textboxPWD.Text & "'"
strTemp = clssql.selectString(strSql)
If strTemp Is Nothing Then
'验证不通过
End If
If strTemp.Trim = textboxPWD.Text.Trim Then
'验证通过
End If
Catch ex As Exception
Finally
End Try
End Sub