title: Insert Data using Json in C#
body: <p>I have some problem in inserting data to my free webhost mysql using JSON in C#. This is what I have done :</p>
  
  <blockquote>
    <p>Php</p>
  </blockquote>
  
  <pre><code>&lt;?php
  
  /*
   * Following code will create a new product row
   * All product details are read from HTTP REQUEST Request
   */
      require_once __DIR__ . '/db_connect.php';
      //require_once __DIR__ . '/generateIDrandom.php';
      require_once __DIR__ . '/Configuration.php';
      $db = new DB_CONNECT();
      $connstring = mysqli_connect(DB_SERVER, DB_USER, DB_PASSWORD, DB_DATABASE);
  
  // array for JSON response
  $response = array();
  
  // check for required fields
  if (isset($_REQUEST['WSID'])) {
      $wsid = $_REQUEST['WSID'];
      $jenismesin = $_REQUEST['JenisMesin'];
      $merk = $_REQUEST['MerkMesin'];
          $lokasi = $_REQUEST['Lokasi'];
      $inlok = $_REQUEST['InisialLokasi'];
      $limit = $_REQUEST['LimitMesin'];
          $denom = $_REQUEST['Denom'];
      $tim4 = $_REQUEST['Tim4'];
      $tim5 = $_REQUEST['Tim5'];
      $status = "1";
  
      // connecting to db
      $result = mysqli_query($connstring, "insert into MasterATM (WSID, JenisMesin, MerkMesin, Lokasi, InisialLokasi, LimitMesin, Denom, Tim4, Tim5, Status) values ('$wsid','$jenismesin','$merk','$lokasi', '$inlok', '$limit', '$denom','$tim4','$tim5','$status')");
  
      // check if row inserted or not
      if ($result) {
          // successfully inserted into database
          $response["success"] = 1;
          $response["message"] = "Upload Successfully";
  
          // echoing JSON response
          echo json_encode($response);
      } else {
          // failed to insert row
          $response["success"] = 0;
          $response["message"] = "Oops! An error occurred.";
  
          // echoing JSON response
          echo json_encode($response);
      }
  } else {
      // required field is missing
      $response["success"] = 0;
      $response["message"] = "Required field(s) is missing";
  
      // echoing JSON response
      echo json_encode($response);
  }
  ?&gt;
  </code></pre>
  
  <blockquote>
    <p>C#</p>
  </blockquote>
  
  <pre><code>private void InputBtn_Click(object sender, EventArgs e)
  {
  try
          {
              WebRequest request = WebRequest.Create("https://xxx.000webhostapp.com/php/InsertDataMesin.php?WSID =" + WSIDBox.Text + "&amp; JenisMesin = " + TipeMesinBox.SelectedItem + "&amp; MerkMesin = " + MerkMesinCB.SelectedItem + "&amp; Lokasi= " + LokasiBox.Text + "&amp; InisialLokasi = " + InisialLokasiBox.Text + "&amp; LimitMesin= " + LimitBox.Text + "&amp; Denom= " + DenomBox.Text + "&amp; Tim4= '" + Tim4CB.SelectedItem + "&amp; Tim5= '" + Tim5CB.SelectedItem + "&amp; Status = 1");
              WebResponse response = request.GetResponse();
              StreamReader stream = new StreamReader(response.GetResponseStream());
              string json = stream.ReadToEnd();
  
              stream.Close();
              var result = JsonConvert.DeserializeObject(json);
  
              MessageBox.Show("Data berhasil ditambahkan !");
  
              TampilDataEdit();
          }
          catch
          {
              MessageBox.Show("Data gagal ditambahkan. Silakan coba lagi");
          }
  }
  </code></pre>
  
  <p>When I run my program, there is no some error. But when I see to my database, there is no data inserted. So, How can I insert data using json c# ? </p>