我遇到问题,当我创建WCF服务时,我用wcftestclient.exe测试它,是的它返回一个就像我想要它的值
但是在winform中,它只是空白,这是我的代码
这是我的datacontract类(dcClient.vb)
Public Class dcClient
Private _userName As String
Private _password As String
Private _userLevel As String
Private _userStatus As String
Public Property userName As String
Get
Return _userName
End Get
Set(value As String)
_userName = value
End Set
End Property
Public Property password As String
Get
Return _password
End Get
Set(value As String)
_password = value
End Set
End Property
Public Property userLevel As String
Get
Return _userLevel
End Get
Set(value As String)
_userLevel = value
End Set
End Property
Public Property userStatus As String
Get
Return _userStatus
End Get
Set(value As String)
_userStatus = value
End Set
End Property
结束班
这是我的ServiceClient.vb
Public Function loginClient(ByVal userName As String, ByVal password As String) As dcClient Implements IServiceClient.loginClient Dim dcClients As New dcClient Dim conString = ConfigurationManager.ConnectionStrings("DBCS").ConnectionString Using con As New SqlConnection(conString) Dim cmd As New SqlCommand("spSelectMasterUser", con) cmd.CommandType = CommandType.StoredProcedure
Dim parameteruserName As New SqlParameter
parameteruserName.ParameterName = "@userName"
parameteruserName.Value = userName
cmd.Parameters.Add(parameteruserName)
Dim parameterPassword As New SqlParameter
parameterPassword.ParameterName = "@password"
parameterPassword.Value = password
cmd.Parameters.Add(parameterPassword)
con.Open()
Dim dtReader As SqlDataReader = cmd.ExecuteReader
While dtReader.Read
dcClients.userName = dtReader("userName").ToString
dcClients.password = dtReader("password").ToString
dcClients.userLevel = dtReader("userLevel").ToString
dcClients.userStatus = dtReader("userStatus").ToString
End While
End Using
Return dcClients
End Function
有我的服务代码,下面是我的客户代码
Private Sub btn_login_Click(sender As Object, e As EventArgs) Handles btn_login.Click Dim I_Sc As New Service_Ref.ServiceClientClient Dim dcClient As New Service_Ref.dcClient Try dcClient = I_Sc.loginClient("kevin", "kevin") Catch ex As Exception MessageBox.Show("Login Failed") End Try Dim username As String = dcClient.userName Dim userlevel As String = dcClient.userLevel Dim userstatus As String = dcClient.userStatus Label4.Text = username Label5.Text = userlevel Label6.Text = userstatus End Sub
在wcftestclient中,当我输入" kevin"," kevin" (那是我的数据库记录),我返回我需要的全部值。但是当我在客户端执行按钮时,它返回空白,没有...我想念的是什么?