如何在vb.net中使用php文件从远程数据库加载数据? [英] How to load data from a remote database using php file in vb.net?
本文介绍了如何在vb.net中使用php文件从远程数据库加载数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在vb.net中尝试过这段代码,但仍然没有运气。我的托管网站上的在线数据库中有一个php文件。我需要在数据库中获取特定数据,就像过道名称一样。如何在vb.net中加载它?提前谢谢。
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.
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文件
'PHP File
<?php
include("config.php");
include("sql.php");
$sql = new sql;
$task = $_POST['task'];
if ($task =="select")
{
$sql->execute_query("SELECT * FROM tbl_aisles");
}
?>
推荐答案
sql = new sql;
sql = new sql;
task =
task =
_POST [' task'];
if (
_POST['task']; if (
这篇关于如何在vb.net中使用php文件从远程数据库加载数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文