title: node sql server insert data to a tabel
body: <p>I have a website how has a form I'd like to get the post data (I already did it) and put it in a database.</p>
  
  <p>The data come as a JSON, and it looks like this:</p>
  
  <pre><code>{ name : "text" , ho : "text" , day : number , m : number } 
  </code></pre>
  
  <p>I also have a SQL server table how has the same columns name meaning: </p>
  
  <ul>
  <li>Col1 = name (<code>nvarchar</code>)  </li>
  <li>Col2 = ho (<code>nvarchar</code>) </li>
  <li>Col3 = day (<code>numeric</code>)</li>
  <li>Col4 = m (<code>numeric</code>)</li>
  </ul>
  
  <p>I am tring to insert data to the data base using nodejs and mssql moudeul.</p>
  
  <p>My code looks like this:</p>
  
  <pre><code>    let config = {/*the info*/}
      //connect to the data base
      const pool = new sql.ConnectionPool(config , function(err){
      if(err) throw err;
      //get the keys and the values
      let colsName enter code here= Object.keys(theDataObj);
      let values = []
      for(let i = 0; i &lt; colsName.length; i++){
           values.push(theDataObj[colsName[i]]);
           console.log(theDataObj[colsName[i]])//check to see what going in
     pool.request().query(`INSERT INTO ${tabelName}(${colsName}) VALUES (${values})` , function(err , result){
   if(err) throw err;
   console.log(result)
  });
      }
  
  });
  </code></pre>
  
  <p>Every time I am trying to run this code doesn't matter if i change stuff it's send me back the same error:</p>
  
  <blockquote>
    <p>there is no col name ${values[0]}</p>
  </blockquote>
  
  <p>I am meaning the value this statement has.</p>
  
  <p>The value in the array values in position 0 or sometimes 1.   </p>
  
  <p>If someone know about a way I can insert data to sql tabel it will save me. In the <a href="https://www.npmjs.com/package/mssql#prepare-statement-callback" rel="nofollow noreferrer">doc</a> there is no good expansion to this.</p>
  
  <p>I am coming from python background when I want to add data like this to a table I am using python pandas df to_sql and setting the sleeting to add the data and not overwrite this.</p>