{"id":641,"date":"2015-11-27T09:31:33","date_gmt":"2015-11-27T00:31:33","guid":{"rendered":"http:\/\/cromi.com\/?p=641"},"modified":"2015-11-27T09:31:33","modified_gmt":"2015-11-27T00:31:33","slug":"c-sqlite-code-sample","status":"publish","type":"post","link":"http:\/\/cromi.com\/?p=641","title":{"rendered":"C# SQLite Code Sample"},"content":{"rendered":"<p><a href=\"http:\/\/cromi.com\/wp-content\/uploads\/2015\/11\/P_20151127-092339.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/cromi.com\/wp-content\/uploads\/2015\/11\/P_20151127-092339.png\" alt=\"P_20151127-092339\" width=\"319\" height=\"238\" class=\"alignnone size-full wp-image-645\" srcset=\"http:\/\/cromi.com\/wp-content\/uploads\/2015\/11\/P_20151127-092339.png 319w, http:\/\/cromi.com\/wp-content\/uploads\/2015\/11\/P_20151127-092339-150x112.png 150w, http:\/\/cromi.com\/wp-content\/uploads\/2015\/11\/P_20151127-092339-300x224.png 300w\" sizes=\"auto, (max-width: 319px) 100vw, 319px\" \/><\/a><\/p>\n<pre lang=\"csharp\">\r\nusing System.Data.SQLite;   \/\/  \ucd94\uac00\r\n<\/pre>\n<pre lang=\"csharp\">string gsFilePath = System.IO.Directory.GetCurrentDirectory();\r\n\/\/  \ud604\uc7ac \ub514\ub809\ud1a0\ub9ac \uac00\uc838\uc624\uae30 \uc704\ud568 \r\n<\/pre>\n<pre lang=\"csharp\">\/\/ select sample\r\n\r\n\t\t\tstring Conn = gsFilePath + \"\/Test.db\";\r\n\t\t\tString dbConnection = String.Format(\"Data Source={0}\", Conn);\r\n\t\t\tSQLiteConnection dbcon = new SQLiteConnection(dbConnection);\r\n\t\t\tdbcon.Open();\r\n\t\t\tSQLiteCommand qry = new SQLiteCommand(\"SELECT * FROM Test order by seq desc  limit 1\", dbcon);\r\n\t\t\tDataTable dattbl = new DataTable();\r\n\t\t\tSQLiteDataReader reader = qry.ExecuteReader();\r\n\t\t\tdattbl.Load(reader);\r\n\t\t\treader.Close();\r\n\t\t\tif (dattbl.Rows.Count &gt; 0)\r\n\t\t\t{\r\n\t\t\t\tstring Temp1= dattbl.Rows[0][0].ToString();\r\n\t\t\t\tint Temp2= int.Parse(dattbl.Rows[0][1].ToString());\r\n\t\t\t\tstring Temp3= dattbl.Rows[0][2].ToString();\r\n\t\t\t\tstring Temp4= dattbl.Rows[0][3].ToString();\r\n\t\t\t\tintTemp5= int.Parse(dattbl.Rows[0][4].ToString());\r\n                         }\r\n\r\n<\/pre>\n<pre lang=\"csharp\">\/\/ insert sample\r\n\t\t\tstring tempQry = string.Empty;\r\n\t\t\ttry\r\n\t\t\t{\r\n\t\t\t\tstring Conn = gsFilePath + \"\/Test2.db\";\r\n\t\t\t\tString dbConnection = String.Format(\"Data Source={0}\", Conn);\r\n\t\t\t\tSQLiteConnection dbcon = new SQLiteConnection(dbConnection);\r\n\t\t\t\tdbcon.Open();\r\n\t\t\t\tSQLiteCommand qry = new SQLiteCommand(\" insert into WIRE (pt_no, SEQ, Wire_Code \r\n                                                                  ,Wire_nm, Wire_gram ) values(\" + temA + ptno + temAE +\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t                  \r\n                                                                                            temA + seq + temAE +\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t         \r\n                                                                                            temA + Wire_Code + temAE +\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t    \r\n                                                                                            temA + Wire_nm + temAE +\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t    \r\n                                                                                            temA + Wire_gram + temA +\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n                                                                                            \")\", dbcon);\r\n\t\t\t\tqry.ExecuteNonQuery();\r\n\t\t\t\tdbcon.Close();\r\n\t\t\t}\r\n\t\t\tcatch (Exception)\r\n\t\t\t{\r\n\t\t\t\tthrow;\r\n\t\t\t}\r\n\t\t}\r\n<\/pre>\n<pre lang=\"csharp\">\/\/ insert sample\r\n\r\n\t\t\tstring tempQry = string.Empty;\r\n\r\n\t\t\tstring Conn = gsFilePath + \"\/TEST2.db\";\r\n\t\t\tString dbConnection = String.Format(\"Data Source={0}\", Conn);\r\n\t\t\tSQLiteConnection dbcon = new SQLiteConnection(dbConnection);\r\n\t\t\tdbcon.Open();\r\n\t\t\tSQLiteCommand qry = new SQLiteCommand(\"delete from Table \", dbcon);\t\t\t\r\n\t\t\tqry.ExecuteNonQuery();\r\n\t\t\tdbcon.Close();\r\n\r\n<\/pre>\n<!-- AddThis Advanced Settings generic via filter on the_content --><!-- AddThis Share Buttons generic via filter on the_content -->","protected":false},"excerpt":{"rendered":"<p>using System.Data.SQLite; \/\/ \ucd94\uac00 string gsFilePath = System.IO.Directory.GetCurrentDirectory(); \/\/ \ud604\uc7ac \ub514\ub809\ud1a0\ub9ac \uac00\uc838\uc624\uae30 \uc704\ud568 \/\/ select sample string Conn = gsFilePath + &#8220;\/Test.db&#8221;; String dbConnection = String.Format(&#8220;Data Source={0}&#8221;, Conn); SQLiteConnection dbcon = new SQLiteConnection(dbConnection); dbcon.Open(); SQLiteCommand qry = new SQLiteCommand(&#8220;SELECT * FROM Test order by seq desc limit 1&#8221;, dbcon); DataTable dattbl = new DataTable(); SQLiteDataReader [&hellip;]<!-- AddThis Advanced Settings generic via filter on get_the_excerpt --><!-- AddThis Share Buttons generic via filter on get_the_excerpt --><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[16,54,252,240,253,53],"class_list":["post-641","post","type-post","status-publish","format-standard","hentry","category-vs2008","tag-c","tag-c-2008","tag-c-sqlite","tag-c2008","tag-sqlite","tag-vs2008-2"],"_links":{"self":[{"href":"http:\/\/cromi.com\/index.php?rest_route=\/wp\/v2\/posts\/641","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/cromi.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/cromi.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/cromi.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/cromi.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=641"}],"version-history":[{"count":4,"href":"http:\/\/cromi.com\/index.php?rest_route=\/wp\/v2\/posts\/641\/revisions"}],"predecessor-version":[{"id":646,"href":"http:\/\/cromi.com\/index.php?rest_route=\/wp\/v2\/posts\/641\/revisions\/646"}],"wp:attachment":[{"href":"http:\/\/cromi.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=641"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/cromi.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=641"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/cromi.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=641"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}