title: C# Transfer Data from ODBC Database to Local SQL Database
body: <p>I have connected to a DB through an ODBC connection. The data is on a server and I have the appropriate permissions and username/password. </p>
  
  <p>I am trying to import some of the data into a local SQL database (.mdf). I suspect my SQL statement is wrong.</p>
  
  <p>The idea is that when a an item is selected from a listBox that the data will be downloaded to the SQL database.
  This has completely stopped any progress on my project. Please help!!!</p>
  
  <pre><code>    public partial class frmNorth : Form
      {
              // variables for the connections 
              private OdbcConnection epnConnection = new OdbcConnection();
              private SqlConnection tempDbConnection = new SqlConnection();
      public frmNorth()
      {
          InitializeComponent();
          // This is for the ePN DB
          epnConnection.ConnectionString = @"Dsn=ePN; uid=username; pwd=myPa$$Word";
          // This is for the local DB
          tempDbConnection.ConnectionString = @"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\TempDB.mdf;Integrated Security=True";
      }
      private void lbxFSR_SelectedIndexChanged(object sender, EventArgs e)
      {
          try //For ePN
          {
              //This is where I need the help &lt;--------------------
              epnConnection.Open();
              tempDbConnection.Open();
              OdbcCommand epnCommamd = new OdbcCommand();
              epnCommamd.Connection = epnConnection;
              string epnQuery =   "INSERT INTO " + tempDbConnection + ".tblTemp (FNCL_SPLIT_REC_ID, PROJ_ID, SALES_SRC_PRC) " +
                                  "SELECT PROJ_FNCL_SPLIT.FNCL_SPLIT_REC_ID,PROJ_FNCL_SPLIT.PROJ_ID,PROJ_FNCL_SPLIT.SALES_SRC_PRC " + 
                                  "FROM " + epnConnection + ".PROJ_FNCL_SPLIT " + 
                                  "WHERE PROJ_ID=" + lbxFSR.Text + "";
              epnCommamd.CommandText = epnQuery;
              epnCommamd.CommandTimeout = 0;
              epnCommamd.ExecuteNonQuery();
  
              epnConnection.Close();
              tempDbConnection.Close();
          }
          catch (Exception ex)
          {
              epnConnection.Close();
              tempDbConnection.Close();
              MessageBox.Show("Error " + ex);
          }
      }
      }
  </code></pre>
  
  <p>This is the error that I get. The error occurs at <strong>epnCommamd.ExecuteNonQuery();</strong></p>
  
  <p><a href="https://i.stack.imgur.com/ft2rp.png" rel="nofollow noreferrer">Picture of Error Message</a></p>