你好,我想提出兩個字符串之間進行比較,首先是在給定的基礎和做其他的從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