I can't load data to show
error at xeProduct = XElement.Load(strLoadSource)
I want data to compare if username or password wrong have messagebox if true exit sub

Private Sub login()
        Dim postData As String
        Dim strLoadSource As String
        Dim xeProduct As XElement
        postData = "username=" & user & "&password=" & pass
        'postData = "username="S2012"&password=S2012"   'correct username and password
        Dim request As HttpWebRequest
        Dim response As HttpWebResponse
        request = CType(WebRequest.Create("http://www.renvi.src.ku.ac.th/anutin/webservice/TestVB/loginXML.php"), HttpWebRequest)
        request.ContentType = "application/x-www-form-urlencoded"
        request.ContentLength = postData.Length
        request.Method = "POST"
        request.AllowAutoRedirect = False

        Dim requestStream As Stream = request.GetRequestStream()
        Dim postBytes As Byte() = Encoding.ASCII.GetBytes(postData)
        requestStream.Write(postBytes, 0, postBytes.Length)
        response = CType(request.GetResponse(), HttpWebResponse)

        ' Console.WriteLine(New StreamReader(response.GetResponseStream()).ReadToEnd())
        strLoadSource = New StreamReader(response.GetResponseStream()).ReadToEnd()
        xeProduct = XElement.Load(strLoadSource)    'error can't load
        Dim MsgError = From pl In xeProduct.Descendants("problem") Select pl.Value

        Dim sb As New StringBuilder
        sb.Remove(0, sb.Length)


        strshow = sb.ToString
        TextBox1.Text = strshow
    End Sub


First question, have you debugged the code and checked strLoadSource has the correct information in it?

This article has been dead for over six months. Start a new discussion instead.