title: Invalid object name 'Main' error when inserting into Database - C# (WebForms), MySql
body: <p>I know plenty of people have these issues, and I've actually tried to implement some of the suggestions to my code, however I'm getting errors that just don't make sense to me. This is my first time implementing database calls to my code. Can someone please tell me what I'm doing wrong? The following error pops up: ERROR: Invalid object name 'Main'. This is actually triggered by my exception so at least something is working. Otherwise, I don't know what the issue is. On the DB end, I have (<code>username VARCHAR, email VARCHAR and number NCHAR</code>) Please see the code below</p>
  <pre><code> static string path = Path.GetFullPath(Environment.CurrentDirectory);
      static string databaseName = &quot;u_DB.mdf&quot;;
  
      string connectionString = @&quot;Data Source=(localdb)\MSSQLLocalDB;AttachDbFilename=&quot; + path + @&quot;\&quot; + databaseName + &quot;; Integrated Security=True;&quot;;
  
      private void button1_Click(object sender, EventArgs e)
      {
          // string query = &quot;INSERT INTO  UserInfo  '&quot; + textBox1.Text + &quot;' and password = '&quot; + textBox2.Text + &quot;'&quot;;
          string query = &quot;insert into Main ([username], [email], [number]) values(@username,@email,@number)&quot;;
  
          using (SqlConnection con = new SqlConnection(connectionString))
          {
              try
              {
                  con.Open();
                  using (SqlCommand cmd = new SqlCommand(query, con))
                  {
                      cmd.Parameters.Add(&quot;@username&quot;, SqlDbType.VarChar).Value = textBox3.Text;
                      cmd.Parameters.Add(&quot;@email&quot;, SqlDbType.VarChar).Value = textBox2.Text;
                      cmd.Parameters.AddWithValue(&quot;@number&quot;, SqlDbType.VarChar).Value = textBox1.Text;
  
                      int rowsAdded = cmd.ExecuteNonQuery();
                      if (rowsAdded &gt; 0)
                          MessageBox.Show(&quot;Added to Database&quot;);
                      else
                          MessageBox.Show(&quot;Nothing was added&quot;);
                  }
  
              }
              catch (Exception ex)
              {
                  MessageBox.Show(&quot;ERROR: &quot; + ex.Message);
              }
              con.Close();
          }
  
      }
  </code></pre>