title: Insert Into Statement doesn't throw an error but Data isn't inserted into table
body: <p>I can't find the answer to this problem anywhere. I'm trying to insert data into a SQL Server table. Everything seems to be OK with the statement, no errors throw when the command executes, but data isn't updated into the table... </p>
  
  <p>Here is my code:</p>
  
  <pre><code>    public Boolean InsertRecordsToDB(string sColumns, String sParameters, string sValues, string sTable)
      {
          /// Split the parameter holding the values for the sql command parameters by the tab character and fill the appropriate arra\
          String[] sMyCols;
          sMyCols = sColumns.Split('\t');
          List&lt;String&gt; lstCols = new List&lt;String&gt;();
          for (int ii = 0; ii &lt; sMyCols.Length; ii++)
          {
              lstCols.Add(sMyCols[ii]);
          }
  
          String[] sMyParams;
          sMyParams = sParameters.Split('\t');
          List&lt;String&gt; lstParams = new List&lt;String&gt;();
          for (int ii = 0; ii &lt; sMyParams.Length; ii++)
          {
              lstParams.Add(sMyParams[ii]);
          }
  
          /// Split the values param and fill the array.  Using the parameter methodology as opposed to concatenating SQL strings prevents
          /// SQL injection
          string[] sMyValues;
          sMyValues = sValues.Split('\t');
          List&lt;String&gt; lstValues = new List&lt;String&gt;();
          for (int ii = 0; ii &lt; sMyValues.Length; ii++)
          {
              lstValues.Add(sMyValues[ii]);
          }
  
          ///  Default connection string for the library project to be opened by the connection object
          String sConnString = LibraryProject.Properties.Settings.Default.db_ConnectionString;
  
          ///First build the Sql string based on the criteria passed in
          String sSql = "";
          sSql = "Insert Into [" + sTable + "] (";
          for (int j = 0; j &lt; sMyCols.Length; j++)
          {
              int iParamLen = sMyCols.Length;
              int iParamMinusOne = iParamLen - 1;
  
              if (j.Equals(iParamMinusOne))
              {
                  sSql += sMyCols[j] + ")";
              }
              else
              {
                  sSql += sMyCols[j] + ",";
              }
  
              if (sSql.Substring(sSql.Length - 1).Equals(")"))
              {
                  break;
              }
          }
  
          sSql += " Values(";
          for (int ii = 0; ii &lt; sMyParams.Length; ii++)
          {
              int iParamLen = sMyParams.Length;
              int iParamLenMinusOne = iParamLen - 1;
              if (ii.Equals(iParamLenMinusOne))
              {
                  sSql += sMyParams[ii].Substring(2) + ")";
              }
              else
              {
                  sSql += sMyParams[ii].Substring(2) + ",";
              }
  
              if (sSql.Substring(sSql.Length - 1).Equals(")"))
              {
                  break;
              }
          }
  
          ///  Create the connection object
          using (SqlConnection oConn = new SqlConnection(sConnString))
          {
              oConn.Open();
              {
  
  
                  try
                  {
                      /// With the connection open instantiate an Sql command object
                      SqlCommand oMyCmd = new SqlCommand(sSql, oConn);
                      oMyCmd.Connection = oConn;
                      oMyCmd.CommandType = CommandType.Text;
                      oMyCmd.CommandText = sSql;
                      int i = 0;
  
                      /// Assign the correct SQLDbType based on the preceding character of the parameter passed in (e.g. s_ = String/Text:  b_ = Boolean: d_ = Date)
                      foreach (String sParam in sMyParams)
                      {
                          switch (sParam.Substring(0, 2))
                          {
                              case "s_":
                                  oMyCmd.Parameters.Add(sParam.Substring(2), SqlDbType.Text);
  
                                  break;
  
                              case "b_":
                                  oMyCmd.Parameters.Add(sParam.Substring(2), SqlDbType.Bit);
                                  break;
  
                              case "d_":
                                  oMyCmd.Parameters.Add(sParam.Substring(2), SqlDbType.Date);
                                  break;
  
                              default:
                                  break;
                          }
  
                          oMyCmd.Parameters[sParam.Substring(2)].Value = lstValues[i];
                          i++;
                      }
                      oMyCmd.ExecuteNonQuery();
                      return true;
                  }
                  catch (Exception e)
                  {
                      e.ToString();
                  }
                  return true;
              }
  
          }
  
      }
  </code></pre>
  
  <p>Somebody please help me, I'm banging my head off of the wall here.</p>
  
  <p>Here is the actual SQL statement after it's built:</p>
  
  <pre><code>Insert Into [tblBook] (ISBN, SERIAL_NUM, SUBJECT, TITLE, AUTHOR, PUBLISHER, GENRE)
  Values(@ISBN, @SERIAL_NUM, @SUBJECT, @TITLE, @AUTHOR, @PUBLISHER, @GENRE)
  </code></pre>
  
  <p>The statement value was copied from the immediate window. I stopped execution at the <code>oMyCmd.ExecuteNotQuery();</code> line.</p>