string query in C Sharp
i am trying to get values from 2 website links
and assign them to a lable using visual studio
one is saying how many players online
http://blackbullstudio.ddns.net:81/Websiteassets/GTA/players.php
the other says if the server is online
http://blackbullstudio.ddns.net:81/Websiteassets/GTA/status.php
so that in the end it will look like in the image
26 Replies
im working in .cs so i think this is the right section
the body of the pages look like this
<body>Online</body>
<body>0/8</body>
it shows only the data i want to get
i tried this
private void Form1_Load(object sender, EventArgs e)
{
String queryString = "http://blackbullstudio.ddns.net:81/Websiteassets/GTA/players.php?";
}
you need to get the label you want to change and set its Text property
e.g.
yeah i get that but the url i get needs to return the data i need
if you right-click on the label and go to 'properties', i think it shows you the name there. been a while since i did winforms
oh, you actually wanna call the page
yeah i need the info thats on the page in the label
Xd
http://blackbullstudio.ddns.net:81/Websiteassets/GTA/players.php
like that one
its says 0/8
i need that text in the label
cause it says how many players there are
it says this
Severity Code Description Project File Line Suppression State
Error CS0029 Cannot implicitly convert type 'System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage>' to 'string' FivemLauncher C:\Users\PC\source\repos\FivemLauncher\FivemLauncher\Form1.cs 24 Active
yeah, i forgot the
await
keyword
need thatlots of red Xd
oh, i know what i'm forgetting
my bad
no worries im allready happy that your helping me
this isn't technically the best way to do things. but it's fine for getting started
and no prob
do i need some models like the
useing system.net
etc
cause some are still red
you know if it works it works simple as that Xd
you will yeah
though i think the error there is different
i have these rn
using System.Net;
using System.Text;
using static System.Formats.Asn1.AsnWriter;
using System.Xml.Linq;
using System.Web;
you need
async
in your method definition
private async voidaah okey
async
lets you use await
, await
lets you make HTTP calls without freezing your app, basicallyaah okey
IT WORKS !!
Thank you soo much
i ahve been strugling with this for like 2 hours now haha
i started using C# today haha
🙂
glad to hear it
everyone struggles at first, don't worry about it
hehe yeah its difrent from what im used to Xd
im mainly a python / web developer
eventually it starts feeling natural
lemme know if there's anything else i can help with
true Xd
i will thanks
!solved