您好,我想对两个字符串进行比较,第一个在给定的基数中,另一个从 检索TextBox
,但结果始终是do
,
Imports System.Data
Imports System.Data.SqlClient
Imports System.Text.RegularExpressions
Public Class Form1
Private Sub Bcon_Click(sender As Object, e As EventArgs) Handles Bcon.Click
Dim cnn As SqlConnection = New SqlConnection("Data Source=BANIX;Initial Catalog=mydb;Integrated Security=True;Connect Timeout=15;Encrypt=False;")
Dim cmd As New SqlCommand("select * from utilisateurs", cnn)
Dim rd As SqlDataReader
Dim sr As String = vbNullString
Try
cnn.Open()
rd = cmd.ExecuteReader
While rd.Read
sr = rd.GetString(1)
RTB.AppendText(Environment.NewLine & "DB login = " & sr)
RTB.AppendText(Environment.NewLine & "TBLogin = " & TBlogin.Text)
RTB.AppendText(Environment.NewLine & "IsMatch sr:" & Regex.IsMatch(TBlogin.Text, sr))
RTB.AppendText(Environment.NewLine & "Equals sr : " & String.Equals(TBlogin.Text, sr))
If (TBlogin.Text = sr) Then
RTB.AppendText(Environment.NewLine & "Identique")
Else
RTB.AppendText(Environment.NewLine & "n'est pas Identique")
End If
End While
rd.Close()
Catch ex As Exception
RTB.AppendText(Environment.NewLine & " cannot connect !")
End Try
cnn.Close()
End Sub
End Class