Forum Xamarin.Android
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

How to create connection mysql with webrequest and php

Hi everyone, I need create an aplication android to connect on mysql server and fill Textview
i used string StringConexaoMysql = "Server=localhost;Database=database;Uid=user;Pwd=pass"; to connect..
but i wanna use webrequest with php file! help me pls!!

Posts

  • zonadevzonadev INMember

    @MarcioCPLgames said:
    Hi everyone, I need create an aplication android to connect on mysql server and fill Textview
    i used string StringConexaoMysql = "Server=localhost;Database=database;Uid=user;Pwd=pass"; to connect..
    but i wanna use webrequest with php file! help me pls!!

    down vote
    An easy solution would be to change your php from post to get

    Just replace $_POST with $_GET

    Now let's go for the code

    String prenom="john";
    String nom="doe";
    String tel="025545";
    String dep="security";
    String com="somecom";
    String adress="street431";
    String courriel="[email protected]";
    // let's build our link
    String link="http://localhost/CRUDSERVICE/CreateContact.php?Nom="+nom+"&Prenom="+prenom+"&Tel="+tel+"&Dep="+dep+"&Com="+com+"&Adress+"+adress+"&Courriel="+courriel;
    WebClient wc=new WebClient(); // don't forget using System.Net;
    String res=wc.DownloadString(link); // res is data printed by echo
    if(res=="No Connection " || res=="Query Failed")
    {
    // something went wrong
    }
    else
    {

    }

  • MarcioCPLgamesMarcioCPLgames USMember ✭✭

    Thanks for your help @zonadev it worked! :smiley:

Sign In or Register to comment.