你好,我想提出两个字符串之间进行比较,首先是在给定的基础和做其他的从TextBox
检索,但结果总是do
,检查两个字符串是否相同的VB网。
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
请确保您的文章都是英文的,谢谢。你还可以提供你收到的任何错误(如果有的话),你试过的东西等,等等...... – Sam 2013-05-01 09:03:21
'结果总是做',这是什么意思? – 2013-05-01 09:04:31
我很难理解这个“......但结果总是**'做**”。无论如何,你能显示RTB的输出吗? – ajakblackgoat 2013-05-01 09:05:11