title: How to insert correct value from DropDownList into Database Table
body: <p>I have a form where an admin can add a company to a database table called 'Company'</p>
  
  <p>In this form there is a Drop Down list to select whether a company is a Scholarship Company, there are two options 'Yes' and 'No'. I have created a table to pull these options from called 'YesNo'.</p>
  
  <p>When I select Yes in the drop down list and hit submit it updates the table so the cell for ScholarshipCompany is '1' and not 'Yes'. This works fine in the edit form I have which just updates the company though I am having trouble with the add company form which inserts a new entry into the table.</p>
  
  <p>Please see code below;</p>
  
  <pre><code>Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
      If Session("Name") = Nothing Then
          Response.Redirect("Login.aspx")
      End If
      Session("Name") = Session("Name")
      Session("Username") = Session("Username")
  
      Try
  
          If Not IsPostBack Then
  
              Dim locationList As OleDbDataReader = Database.DoSQLReturnDataReader("SELECT [{Location}].ID, [{Location}].Location FROM [{Location}] ORDER BY [{Location}].ID")
              ddlLocation.DataSource = locationList
              ddlLocation.DataTextField = "Location"
              ddlLocation.DataValueField = "ID"
              ddlLocation.DataBind()
              locationList.close()
  
              Dim statusList As OleDbDataReader = Database.DoSQLReturnDataReader("SELECT *  FROM EmployerStatus  ORDER BY ID ASC")
              ddlStatus.DataSource = statusList
              ddlStatus.DataTextField = "Status"
              ddlStatus.DataValueField = "ID"
              ddlStatus.DataBind()
              statusList.close()
  
              Dim yesnoList As OleDbDataReader = Database.DoSQLReturnDataReader("SELECT * FROM YesNo ORDER BY ID DESC")
              ddlYesno.DataSource = yesnoList
              ddlYesno.DataTextField = "Option"
              ddlYesno.DataValueField = "Option"
              ddlYesno.DataBind()
              yesnoList.close()
  
          End If
  
      Catch ex As Exception
          Response.Redirect("index.aspx?Yr=" &amp; Replace(Request.QueryString("Yr"), "'", "''"))
      End Try
  End Sub
  
  
  Protected Sub BtnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles BtnSubmit.Click
  
      Dim strSql As String = "INSERT INTO Company(" &amp; _
      "CompanyName, " &amp; _
      "URL, " &amp; _
      "Location, " &amp; _
      "EmployerStatus, " &amp; _
      "Address, " &amp; _
      "ScholarshipCompany, " &amp; _
      "ScholarshipNotes, " &amp; _
      "Town, " &amp; _
      "County, " &amp; _
      "Blurb, " &amp; _
      "InterviewTips, " &amp; _
      "HRContactForename, " &amp; _
      "HRContactSurname, " &amp; _
      "HREmail, " &amp; _
      "Telephone, " &amp; _
      "[Password], " &amp; _
      "Fax, " &amp; _
      "HRContactForename2, " &amp; _
      "HRContactSurname2, " &amp; _
      "HREmail2, " &amp; _
      "Telephone2, " &amp; _
      "HRContactForename3, " &amp; _
      "HRContactSurname3, " &amp; _
      "HREmail3, " &amp; _
      "Telephone3, " &amp; _
      "Postcode) " &amp; _
      "VALUES " &amp; _
      "( " &amp; _
      "'" &amp; TxtBoxCompanyName.Text.Replace("'", "''") &amp; "', " &amp; _
      "'" &amp; TxtBoxURL.Text.Replace("'", "''") &amp; "', " &amp; _
      "'" &amp; Replace((ddlLocation.SelectedIndex + 1), "'", "''") &amp; "', " &amp; _
      "'" &amp; Replace((ddlStatus.SelectedIndex + 1), "'", "''") &amp; "', " &amp; _
      "'" &amp; TxtAreaAddress.InnerText.Replace("'", "''") &amp; "', " &amp; _
      "'" &amp; Replace((ddlYesno.SelectedIndex), "'", "''") &amp; "', " &amp; _
      "'" &amp; TxtBoxSchol.Text.Replace("'", "''") &amp; "', " &amp; _
      "'" &amp; TxtBoxTown.Text.Replace("'", "''") &amp; "', " &amp; _
      "'" &amp; TxtBoxCounty.Text.Replace("'", "''") &amp; "', " &amp; _
      "'" &amp; "" &amp; "', " &amp; _
      "'" &amp; "" &amp; "', " &amp; _
      "'" &amp; "" &amp; "', " &amp; _
      "'" &amp; "" &amp; "', " &amp; _
      "'" &amp; "" &amp; "', " &amp; _
      "'" &amp; "" &amp; "', " &amp; _
      "'" &amp; "" &amp; "', " &amp; _
      "'" &amp; "" &amp; "', " &amp; _
      "'" &amp; "" &amp; "', " &amp; _
      "'" &amp; "" &amp; "', " &amp; _
      "'" &amp; "" &amp; "', " &amp; _
      "'" &amp; "" &amp; "', " &amp; _
      "'" &amp; "" &amp; "', " &amp; _
      "'" &amp; "" &amp; "', " &amp; _
      "'" &amp; "" &amp; "', " &amp; _
      "'" &amp; "" &amp; "', " &amp; _
      "'" &amp; TxtBoxPostcode.Text.Replace("'", "''") &amp; "'" &amp; _
      ")"
  
      Dim updateCompanyDetails As OleDbDataReader = Database.DoSQLReturnDataReader(strSql)
      updateCompanyDetails.Close()
      System.Threading.Thread.Sleep("1000")
  </code></pre>