title: How to save combobox items in database using the insert into query?
body: <p>I want to save account in login database using combobox.</p>
  
  <p>When I try to save, I'm presented with the error: "Syntax error in INSERT INTO statement". I tried to find the error in my INSERT INTO statement but i was unable to figure out whats wrong. This is the code I used to add items in combobox:</p>
  
  <pre><code>cmbAccountType2.DropDownStyle = ComboBoxStyle.DropDownList;
          string str = null;
          str = "User";
          cmbAccountType2.Items.Add(str);
          str = "Administrator";
          cmbAccountType2.Items.Add(str);   
  </code></pre>
  
  <p>And this is the query I used to saved the account in my login database:</p>
  
  <pre><code>private void btnSaveAccount_Click_1(object sender, EventArgs e)
      {
  
          DialogResult result = MessageBox.Show("Do you want to save item?", "Confirmation", MessageBoxButtons.YesNo);
  
          if (result == DialogResult.Yes)
          {
              string q = "INSERT INTO LoginDB (userName, password, accountType) VALUES ('" + txtUserName1.Text.ToString() + "', '" + txtPassword1.Text.ToString() + "', , '" + cmbAccountType2.Text.ToString() + "')";
                  doSomething(q);               
          }
          else if (result == DialogResult.No)
          {
              MessageBox.Show("Transaction cancelled.", "Information");
              textClear();
          }              
          loadData();
      }
  </code></pre>