{"id":133,"date":"2006-09-13T14:10:35","date_gmt":"2006-09-13T13:10:35","guid":{"rendered":"http:\/\/www.galhano.com\/blog\/?p=133"},"modified":"2006-09-13T14:10:35","modified_gmt":"2006-09-13T13:10:35","slug":"metodo-commandexecutescalar","status":"publish","type":"post","link":"http:\/\/galhano.com\/blog\/?p=133","title":{"rendered":"M\u00c3\u00a9todo Command.ExecuteScalar"},"content":{"rendered":"<p>Use the <strong>ExecuteScalar<\/strong> method to retrieve a single value (for example, an  \t\t\t\taggregate value) from a database. This requires less code than using the <strong> \t\t\t\t\tExecuteReader<\/strong> method, and then performing the operations necessary to  \t\t\t\tgenerate the single value from the data returned by a  <strong>DataReader<\/strong>.<\/p>\n<p>A typical <strong>ExecuteScalar<\/strong> query can be formatted as in the following VB  \t\t\t\texample:<\/p>\n<p><!-- START NON-TRANSLATABLE --><\/p>\n<blockquote>\n<pre class=\"code\">conn = New Data.SqlClient.SqlConnection(strConn)<\/pre>\n<pre class=\"code\">cmd = New Data.SqlClient.SqlCommand(sSQL, conn)<\/pre>\n<pre class=\"code\">Dim ValorDB as Integer = cmd.ExecuteScalar()<\/pre>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>Use the ExecuteScalar method to retrieve a single value (for example, an aggregate value) from a database. This requires less code than using the ExecuteReader method, and then performing the operations necessary to generate the single value from the data returned by a DataReader. A typical ExecuteScalar query can be formatted as in the following [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"close","ping_status":"close","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-133","post","type-post","status-publish","format-standard","hentry","category-aspnet","author-admin"],"_links":{"self":[{"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/133","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=133"}],"version-history":[{"count":0,"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/133\/revisions"}],"wp:attachment":[{"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=133"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=133"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=133"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}