How to send data from vb.net application to a web server?

The application that I created in visual studio receives its data from the user's PC, currently stores it in a text file, uploads it to the server, and this is how I get the data. I was wondering if there is a way to send the same data without using text files, but can some kind of TCP connection be directly to mysql server using php? How to do it?

+4
source share
2 answers

You can write a simple PHP web service , "uploaddata.php":

<?php if (isset($_POST["data"])) { echo("Saved these data: " . $_POST["data"]); } else { echo "ERROR: No data!"; } ?> 

And use it from VB.Net using WebClient :

 Dim wc As New WebClient wc.Headers("content-type") = "application/x-www-form-urlencoded" Dim response As String = wc.UploadString("http://localhost/uploaddata.php", "data=123" & Environment.NewLine & "456" & Environment.NewLine & "789") MessageBox.Show(response) 

Result:

 Saved these data: 123 456 789 
+3
source

Looking for a solution to this problem, I found Pragmateek's suggestion good. However, I used the WebBrowser variable and called the Move as parameter parameter the URL with the data that I wanted to update in my database (hosted on the web server).

This is what I mean.

 Dim br As New WebBrowser br.Navigate("http://yourwebsite/your-php-script.php?your_variable=" + the_data_you_want_to_send) 

This works well for me .. good luck!

0
source

Source: https://habr.com/ru/post/1487634/


All Articles