【发布时间】:2013-11-28 09:00:57
【问题描述】:
listener = New TcpListener(System.Net.IPAddress.Any, portconnect)
listener.Start()
client = listener.AcceptTcpClient
loginInfo = receivedata()
Dim array() As String
array = loginInfo.Split("|")
username = array(0)
pass = array(1)
客户端发送到服务器的信息是登录信息。我将 logininfo 输入用户名和密码。
Public Function authentication(ByVal user As String, ByVal pass As String) As Boolean
Dim authentica As Boolean = False
Dim con As New OleDbConnection
Try
con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & " data source= " & Application.StartupPath & "\" & dataName
Dim myCommand As OleDbCommand = con.CreateCommand()
Dim sqlstr As String = ""
sqlstr = "Select password from tbusers where Username = " & "'" & user & "'"
myCommand.CommandText = sqlstr
con.Open()
Dim passw As String
passw = myCommand.ExecuteScalar()
con.Close()
If pass = passw Then
authentica = True
End If
Catch ex As Exception
MsgBox(ex.ToString)
End Try
Return authentica
End Function
问题是:If pass = passw Then authentica = True End If
总是返回 false。
请帮忙
【问题讨论】:
-
不,我认为,当客户端发送数据时,数据是被封装的。调试,用户是用户名和newstr =“用户名”。 boolean user = newstr ,它返回 false
-
请显示您已经有哪些代码不起作用
标签: .net vb.net string parsing client-server