I have a webmethod in vb.net and I use a list of objects to store values of the SQL query that I do, but when compiling I get an error saying that value.user is not a member of Login, Login is a class where I declare properties
<WebMethod()>
Public Shared Function Login(ByVal userid As String, ByVal password As String) As List(Of Login)
Dim datosLogin As New List(Of Login)
Dim cn = ConfigurationManager.ConnectionStrings("cadenaConexion").ConnectionString
Dim conexion As New SqlConnection(cn)
Dim cmd As New SqlCommand("SELECT * FROM usuarios WHERE Usuario='" & userid & "' AND Contrasena='" & password & "'")
cmd.Connection = conexion
conexion.Open()
Dim loginok As String
loginok = "Page.html"
Dim dr As SqlDataReader
dr = cmd.ExecuteReader()
If dr.HasRows Then
While dr.Read()
Dim valor As New Login
valor.usuario = Convert.ToString(dr.GetString(1))
valor.password = Convert.ToString(dr.GetString(2))
valor.sofware = Convert.ToString(dr.GetString(5))
valor.redireccionar = loginok
datosLogin.Add(valor)
End While
End If
Return datosLogin
End Function
Login class
Public Class Login
Public Property usuario As String
Public Property password As String
Public Property software As String
Public Property redireccionar As String
End Class
The error is apparently because in your project you have created a file called Login.aspx, so in the codeBehind, it also creates a Login class for you, so in the webMethod that you create and initialize the Login class, it is taking that class, not the what did you create I recommend you change the name of the Login class to something else and try.
and so your WebMethod:
Actually the problem is that it can't find the "software" property, because it's misspelled, missing a "t" character:
Review the definition in class:
In the console it also shows another detail:
It should be
´software´
, review your codeIndex.aspx
and make sure you write the properties correctly.