Click here to Skip to main content
15,891,951 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I tried this code in vb.net but still no luck. I have a php file in my online database in my hosting site. I need to get specific data in my database like the aisle names only. how to load it in vb.net? Thankyou in advance.


VB
Dim postData As String = "task=select"
Dim tempCookies As New CookieContainer
Dim encoding As New UTF8Encoding
Dim byteData As Byte() = encoding.GetBytes(postData)

Dim postReq As HttpWebRequest = DirectCast(WebRequest.Create("http://www.sample.com"), HttpWebRequest)
postReq.Method = "POST"
postReq.KeepAlive = True
postReq.CookieContainer = tempCookies
postReq.ContentType = "application/x-www-form-urlencoded"
postReq.Referer = "http://www.sample.com"
postReq.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 6.1; ru; rv:1.9.2.3) Gecko/20100401 Firefox/4.0 (.NET CLR 3.5.30729)"
postReq.ContentLength = byteData.Length

Dim postreqstream As Stream = postReq.GetRequestStream()
postreqstream.Write(byteData, 0, byteData.Length)
postreqstream.Close()
Dim postresponse As HttpWebResponse

postresponse = DirectCast(postReq.GetResponse(), HttpWebResponse)
tempCookies.Add(postresponse.Cookies)
logincookie = tempCookies
Dim postreqreader As New StreamReader(postresponse.GetResponseStream())

Dim thepage As String = postreqreader.ReadToEnd

RichTextBox1.Text = thepage



'PHP File
PHP
<?php
    include("config.php");
    include("sql.php");

    $sql = new sql;

    $task = $_POST['task'];



if ($task =="select")
    {
        $sql->execute_query("SELECT * FROM tbl_aisles");
    }


?>
Posted

1 solution

In this case, the PHP is acting as web service. Check this out: setting-up-a-php-web-service-mysql-to-be-consumed-by-vbnet/[^]
 
Share this answer
 
Comments
Kim Paulene Opulencia 18-Jan-15 21:13pm    
Sir still no idea. thankyou

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900