{"id":4231,"date":"2014-03-30T09:24:47","date_gmt":"2014-03-30T09:24:47","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/error-incorrect-syntax-near-14-collection-of-common-programming-errors\/"},"modified":"2014-03-30T09:24:47","modified_gmt":"2014-03-30T09:24:47","slug":"error-incorrect-syntax-near-14-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/error-incorrect-syntax-near-14-collection-of-common-programming-errors\/","title":{"rendered":"Error: Incorrect syntax near &#39;14&#39;-Collection of common programming errors"},"content":{"rendered":"<p>I have to insert values in the table using insert query&#8230;the table stored in the database has 3 columns: 1. Date (DateTime) 2. SensorValue (Float) 3. Difference (Float) Now the values for each column comes from datagridview&#8230;..here is the button&#8217;s code for inserting<\/p>\n<pre><code>con.ConnectionString = \"Data Source=.\\\\SQLEXPRESS;AttachDbFilename=C:\\\\dbsave.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True\";\nif (con.State == ConnectionState.Closed)\n{\n    con.Open();\n}\nfor (Int32 i = 0; i &lt; dataGridView1.Rows.Count-1; i++)\n{\n    String query1 = \n        \"INSERT INTO \" + tbName + \n        \" ( Date, SensorValue, Difference) \" + \"VALUES (\" +     \n        dataGridView1.Rows[i].Cells[0].Value + \",\" + \n        dataGridView1.Rows[i].Cells[1].Value + \",\" + \n        dataGridView1.Rows[i].Cells[2].Value + \")\";\n    SqlCommand cmd1 = new SqlCommand(query1, con);\n    cmd1.ExecuteNonQuery();\n}\ncon.Close();\nMessageBox.Show(\"The table has been saved\");\n<\/code><\/pre>\n<p>The error is ofcourse in execution of the query&#8230;.the first entry in the date column is the value: 12\/05\/2012 14:32:00&#8230;.so basically the sql is not accepting the colon that is placed with 14&#8230;.how can i solve this problem ? please help<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I have to insert values in the table using insert query&#8230;the table stored in the database has 3 columns: 1. Date (DateTime) 2. SensorValue (Float) 3. Difference (Float) Now the values for each column comes from datagridview&#8230;..here is the button&#8217;s code for inserting con.ConnectionString = &#8220;Data Source=.\\\\SQLEXPRESS;AttachDbFilename=C:\\\\dbsave.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True&#8221;; if (con.State == ConnectionState.Closed) { [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-4231","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4231","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=4231"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4231\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=4231"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=4231"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=4231"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}