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)
        requestStream.Close()
        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)

        sb.Append(MsgError)

        strshow = sb.ToString
        MessageBox.Show(strshow)
        TextBox1.Text = strshow
    End Sub

please.......

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.