title: Why am I getting, "cannot find table 0"?
body: <p>At program startup, I'm creating a SQL Server CE table if it doesn't exist, and adding a record to it:</p>
  
  <pre><code>if (dbconn.isValidTable("hhs_settings") == -1) // &lt;-- (IOW, it's *not* a valid table)
  {
      DBUtils.CreateSettingsTable();
      AppSettings.WriteSettingsVal("beltprinter", "None");
  }
  
  public static void CreateSettingsTable()
  {
      try
      {
          string sqlddl =
              "create table hhs_settings (setting_id int identity (1,1) Primary key,  setting_name varchar(40) not null, setting_value(63) varchar not null)";
          dbconn.DBCommand(sqlddl, false);        
      }
      catch (SqlCeException sqlcex)
      {
          MessageBox.Show("sqlcex - CreateSettingsTable " + sqlcex.Message);
      }
      catch (Exception ex)
      {
          MessageBox.Show("CreateSettingsTable " + ex.Message);
      }
  }
  </code></pre>
  
  <p>...but then when I open a form that reads from the table:</p>
  
  <pre><code>lblSelectedPrinter.Text = AppSettings.ReadSettingsVal("beltprinter");
  </code></pre>
  
  <p>...it fails with "<strong><em>cannot find table 0</em></strong>"</p>
  
  <pre><code>public static string ReadSettingsVal(string settingName)
  {
      string retVal = string.Empty;
      string sqldml = string.Format("select setting_value from hhs_settings where setting_name = {0}", " + settingName + ");
      // There should only be one value returned, but using the existing getDataSet() method for now...
      DataSet dsSettingVal = frmCentral.dbconn.getDataSet(sqldml);
      foreach (DataRow row in dsSettingVal.Tables[0].Rows)
      {
          if (retVal == string.Empty)
          {
              retVal = row["setting_value"].ToString();
          }
      }
      return retVal;
  }
  </code></pre>
  
  <p>Am I missing a step here, so that the table (hhs_settings) is not being created? Or...???</p>
  
  <h2>UPDATE</h2>
  
  <p>I'm still getting the same err msg even after changing all of the goofily formatted strings so that they are now:</p>
  
  <pre><code>string sqldml = string.Format("insert into hhs_settings (setting_name, setting_value) values('{0}', '{1}')", settingName, settingVal);
  string sqlqry = string.Format("select setting_value from hhs_settings where setting_name = '{0}'", settingName);
  </code></pre>
  
  <p>And, I'm still seeing the msg "about to create hhs_settings" even though, presumably, the createtable sql was already good:</p>
  
  <pre><code>string sqlddl =
      "create table hhs_settings (setting_id int identity (1,1) Primary key,  setting_name varchar(40) not null, setting_value(63) varchar not null)";
  </code></pre>
  
  <p>...and so, the table should have been created (which should have made the isValidTable() method return something other than -1 (the value it returns when the table is not found).</p>
  
  <h2>UPDATE 2</h2>
  
  <p>It helped (it works now) when I changed my ddl to:</p>
  
  <p>string sqlddl =
          "create table hhs_settings (setting_id int identity (1,1) Primary key,  setting_name nvarchar(40) not null, setting_value nvarchar(63) not null)";</p>