title: Radio button value in SQL database
body: <p>I am working on basic website with a SQL database using Visual Studio 2013. On the sign up form there are radio button selections of male or female. Im using asp.net.</p>
  
  <pre><code>&lt;div class="radio-inline" style="padding-left: 0px;"&gt;
      &lt;label class="labelinput"&gt;Gender:&lt;/label&gt;
      &lt;label class="radio-inline"&gt;
          &lt;input class="radio" type="radio" value="male" id="male"     
              name="gender" checked="checked"/&gt;
          &lt;p style="margin: 0; padding-left: 20px; color: black; 
              font-size: 1.4em;"&gt;Male&lt;/p&gt;
      &lt;/label&gt;
      &lt;label class="radio-inline"&gt;
          &lt;input class="radio" type="radio" value="female" id="female" name="gender" /&gt;
          &lt;p style="margin: 0; padding-left: 20px; color: black;
              font-size: 1.4em;"&gt;Female&lt;/p&gt;
      &lt;/label&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>What I tried doing was adding a column of 'gender' in the database. Then in the c# part I wrote this:</p>
  
  <pre><code>string gender = Request.Form["gender"];
  </code></pre>
  
  <p>I use a class that contains functions to connect to the database. The class's name is 'Eitan'. One of the functions is to connect to the database and perform the sql line:</p>
  
  <pre><code>public static void DoQuery(string fileName, string sql)
  {
      SqlConnection conn = ConnectToDb(fileName);
      conn.Open();
      SqlCommand com = new SqlCommand(sql, conn);
      com.ExecuteNonQuery();
      com.Dispose();
      conn.Close();
  }
  </code></pre>
  
  <p>My sql line is:</p>
  
  <pre><code>string sql;
  sql = "insert into users(fullname, username, password, email, cell, birthday, adress, gender)";
  sql += " values('" + fullname + "','" + username + "','" + password + "','" + email + "','" + cell + "','" + birthday + "','" + adress + "','" + gender + "')";
  </code></pre>
  
  <p>(I have more than just the gender) The filename (database file name):  </p>
  
  <pre><code>string filename = "database.mdf";
  </code></pre>
  
  <p>So I use the function with the filename and sql sentence, and when I fill out the form and press submit it brings me back to 'com.ExecuteNonQuery();' in the function DoQuery and shows me this error:</p>
  
  <blockquote>
    <p>An exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.dll but was not handled in user code Additional information: Invalid column name 'gender'.</p>
  </blockquote>
  
  <p>Any ideas what I should do?</p>