{"id":417,"date":"2008-10-15T16:10:28","date_gmt":"2008-10-15T15:10:28","guid":{"rendered":"http:\/\/www.galhano.com\/blog\/?p=417"},"modified":"2008-10-15T16:22:44","modified_gmt":"2008-10-15T15:22:44","slug":"funcao-createdatasetbyval-strsql-as-string","status":"publish","type":"post","link":"http:\/\/galhano.com\/blog\/?p=417","title":{"rendered":"Fun\u00c3\u00a7\u00c3\u00a3o &#8220;CreateDataSet(ByVal strSQL)&#8221;"},"content":{"rendered":"<p>Fun\u00c3\u00a7\u00c3\u00a3o \u00c3\u00batil quando se pretende aceder de forma r\u00c3\u00a1pida a dados de uma tabela:<\/p>\n<pre>Function CreateDataSet(ByVal strSQL) As Data.DataSet\r\n\u00c2 \u00c2 \u00c2 \u00c2 \u00c2 \u00c2 \u00c2  Dim conn As Data.SqlClient.SqlConnection = New Data.SqlClient.SqlConnection(strConn)\r\n\u00c2 \u00c2 \u00c2 \u00c2 \u00c2 \u00c2 \u00c2  Dim cmd As New System.Data.SqlClient.SqlCommand(strSQL, conn)\r\n\u00c2 \u00c2 \u00c2 \u00c2 \u00c2 \u00c2 \u00c2  Dim da As New System.Data.SqlClient.SqlDataAdapter(cmd)\r\n\u00c2 \u00c2 \u00c2 \u00c2 \u00c2 \u00c2 \u00c2  Dim ds As New Data.DataSet\r\n\u00c2 \u00c2 \u00c2 \u00c2 \u00c2 \u00c2 \u00c2  da.Fill(ds)\r\n\u00c2 \u00c2 \u00c2 \u00c2 \u00c2 \u00c2 \u00c2  conn.Close()\r\n\u00c2 \u00c2 \u00c2 \u00c2 \u00c2 \u00c2 \u00c2  conn.Dispose()\r\n\u00c2 \u00c2 \u00c2 \u00c2 \u00c2 \u00c2 \u00c2  Return ds\r\nEnd Function<\/pre>\n<p>Acedendo aos valores:<\/p>\n<pre>label1.text = CreateDataSet(\" SELECT ClienteID, Nome FROM Clientes WHERE ClienteID=23\").Tables(0).Rows(0).Item(1).ToString<\/pre>\n<pre><\/pre>\n<pre><span style=\"font-size: x-small;\"><\/span>\u00c2 <\/pre>\n<pre><span style=\"font-size: x-small;\"><span style=\"font-size: x-small;\">-&gt; Z\u00c3\u00a9 Carlos<\/span><\/span><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Fun\u00c3\u00a7\u00c3\u00a3o \u00c3\u00batil quando se pretende aceder de forma r\u00c3\u00a1pida a dados de uma tabela: Function CreateDataSet(ByVal strSQL) As Data.DataSet \u00c2 \u00c2 \u00c2 \u00c2 \u00c2 \u00c2 \u00c2 Dim conn As Data.SqlClient.SqlConnection = New Data.SqlClient.SqlConnection(strConn) \u00c2 \u00c2 \u00c2 \u00c2 \u00c2 \u00c2 \u00c2 Dim cmd As New System.Data.SqlClient.SqlCommand(strSQL, conn) \u00c2 \u00c2 \u00c2 \u00c2 \u00c2 \u00c2 \u00c2 Dim da [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"close","ping_status":"close","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[28],"tags":[170],"class_list":["post-417","post","type-post","status-publish","format-standard","hentry","category-aspnet-20","tag-aspnet","author-admin"],"_links":{"self":[{"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/417","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=417"}],"version-history":[{"count":0,"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/417\/revisions"}],"wp:attachment":[{"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=417"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=417"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=417"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}