954,514 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

load XML from server

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.......

ryma
Newbie Poster
4 posts since Jul 2010
Reputation Points: 10
Solved Threads: 0
 

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

hericles
Practically a Posting Shark
823 posts since Nov 2007
Reputation Points: 136
Solved Threads: 167
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You