{"id":3781,"date":"2014-03-30T05:35:03","date_gmt":"2014-03-30T05:35:03","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/vb-netrelated-issues-collection-of-common-programming-errors\/"},"modified":"2014-03-30T05:35:03","modified_gmt":"2014-03-30T05:35:03","slug":"vb-netrelated-issues-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/vb-netrelated-issues-collection-of-common-programming-errors\/","title":{"rendered":"vb.netRelated issues-Collection of common programming errors"},"content":{"rendered":"<ul>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/b26632306ca0c9e7642f4842263045d6?s=32&amp;d=identicon&amp;r=PG&amp;f=1\" \/><br \/>\nDholakiya Ankit<br \/>\nsql .net vb.net odbc ironspeed<br \/>\nDim cnnStr As String = &#8220;Provider=Microsoft.Jet.OLEDB.4.0;Data Source=&#8221; + filepath + filenameDim cnn As OleDbConnection = New OleDbConnection(cnnStr)Trycnn.Open()Catch ex As ExceptioncnnStr = &#8220;Provider=Microsoft.Jet.OLEDB.4.0;Data Source=&#8221; + filepath + filenamecnn = New OleDbConnection(cnnStr)cnn.Open()End Try Dim ConnectionString As String = &#8220;Trusted_Connection=no;Server=AMAZONA-RPKEMQI;Database=ContactManager;Uid=sa;Pwd=Sql12345;&#8221;Dim Accesscmd As New OleDbCommandAccesscmd.Connection = cnn&#8217;Acces<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/e7217e24a16aa10f3251691f68f161e5?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nDan J<br \/>\nvb.net extension-methods<br \/>\nWhen attempting to use the Enumerable.Count() extension method from Visual Basic, the following code results in a compile-time error:Imports System.LinqModule Module1Sub Main()Dim l As New List(Of Foo) From {New Foo(&#8220;a&#8221;), New Foo(&#8220;b&#8221;), New Foo(&#8220;a&#8221;)}Dim i As Integer = l.Count(Function(foo) foo.Bar = &#8220;a&#8221;)Console.WriteLine(i)Console.ReadLine()End SubClass FooSub New(ByVal bar As String)Me.Bar = barEnd SubPublic Property Bar As StringEnd Class End ModuleThe error produced is:&#8217;Public ReadOnly Propert<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/33f12c2270fa9d3627845b9f41a08f4f?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nHeinzi<br \/>\nc# java vb.net language-agnostic try-catch-finally<br \/>\nI understand how try-catch works and how try-finally works, but I find myself using those (usually) in two completely different scenarios:try-finally (or using in C# and VB) is mostly used around some medium-sized code block that uses some resource that needs to be disposed properly. try-catch is mostly used either around a single statement that can fail in a very specific way or (as a catch-all) at a very high level of the application, usually directly below some user interface action.In my ex<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/d23b2cf9de6548618d481fd39afd5d66?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nmattmc3<br \/>\nvb.net<br \/>\nWhat are the pros and cons of standardizing on using Option Compare Text vs Option Compare Binary for VB.NET development?&#8212; EDIT &#8212;Just some background since it seems like it would help &#8211; my development team has found it much easier to standardize on Option Strict On, Option Infer On, and Option Explicit due to their obvious advantages over the alternatives. What we haven&#8217;t found as easy to standardize on is Option Compare Text\/Binary as there seem to be advantages and disadvantages to both a<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/1719392531c762e6f4f09a254850997f?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nAlex Essilfie<br \/>\nvb.net casting directcast ctype<br \/>\nEver since I moved from VB6 to VB.NET somewhere in 2005, I&#8217;ve been using CType to do casting from one data type to another. I do this because it is simply faster to type, used to exist in VB6 and I do not know why I have to be using DirectCast if there is apparently no difference between them.I use TryCast once in a while because I understand that sometimes casting can fail. I however cannot get the difference between CType and DirectCast.Can anyone tell me the difference in plain simple English<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/a8e7f0604caeaeda21534e9624ac1009?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nMarie J<br \/>\nasp.net database vb.net visual-studio<br \/>\nI am pretty new to VB and I am not sure why this is not working, basically I am trying to run a stored procedure from my web code. The sp runs just fine in SQL, I&#8217;ve tried it several times so I am sure that is not the problem. I don&#8217;t want to return any results, I just want to see an &#8220;ok&#8221; statement if it runs and an error message if it doesn&#8217;t. The code I am using for the lables (warnings and confirmation) is reused from earlier on the same page, the same goes for the validations (valUpload). I<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/i.stack.imgur.com\/MbIFT.jpg?s=32&amp;g=1\" \/><br \/>\ndevoured elysium<br \/>\nc# .net vb.net bitmap equals<br \/>\nFrom MSDN documentation, it seems as both GetHashCode() and Equals() haven&#8217;t been overriden in Bitmap. Neither have them been overriden in Image. So both classes are using the Object&#8217;s version of them just compares references. I wasn&#8217;t too convinced so I decided to fire up Reflector to check it out. It seems MSDN is correct in that matter.So, is there any special reason why MS guys wouldn&#8217;t implement &#8220;comparison logic&#8221;, at least for the Bitmap class? I find it is kinda acceptable for Image, as i<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/b4286b62fb44962f49756ecb26a754c2?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nAndrei<br \/>\nasp.net html vb.net data-binding dataset<br \/>\nCurrently I am binding a dataset with a datagrid.ds = query.ExecuteReadQuery(&#8220;select PollQuestionText as &#8216;Survey Question&#8217;, PollAnswer1Text as &#8216;Selection 1&#8217;, PollAnswer2Text as &#8216;Selection 2&#8217;, PollAnswer3Text as &#8216;Selection 3&#8217;, PollEnabled &#8216;Status&#8217; from tbl_pollquestions&#8221;)For Each row As Data.DataRow In ds.Tables(0).RowsIf row.ItemArray(4).ToString = &#8220;0&#8221; Thenrow.ItemArray.&#8221;&lt;a href=&#8221;&#8221;&#8221;&#8221;&gt; &lt;img src=&#8221;&#8221;img\/box_icon_edit_pencil1.gif&#8221;&#8221; border=&#8221;&#8221;0&#8243;&#8221;&gt; &lt;\/a&gt;&#8221;ElseIf row.ItemArray(4).T<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/88e60659e997d36af3ff348b3251e1a6?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nTshepang<br \/>\nvb.net excel exception popup alerts<br \/>\nThis is my first time posting in stackoverflow. I started learning VB 2010 yesterday (though I do know some Ruby) and have googled this problem a lot but haven&#8217;t found much. I&#8217;ve written a program that takes a CSV list of filepaths (all .XLS files) and attempts to open them. These excel workbooks were flagged as unreadable by another program; my program tries to capture the warning, popup, or exception that caused the error. It works for most exceptions (password protected, Unreadable Conten<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/d4b1e130573342d48bd0936183fce628?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nCal<br \/>\nasp.net vb.net loops foreach datatable<br \/>\nI have a datatable and I want to convert one row to a single string with all the column names, so the format will be like: column1_name: column1_content. column2_name: column2_content&#8230;I almost got it done the way I wanted, except that the result will be the same string repeated twice. For example, a string &#8220;abc&#8221; is what I want, but it will return &#8220;abcabc&#8221;.It&#8217;s ok when I had only 1 row, I could use exit keyword to terminate the loop after 1 run, but now I have datatables with more than 1 row,<\/li>\n<\/ul>\n<p>Web site is in building<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Dholakiya Ankit sql .net vb.net odbc ironspeed Dim cnnStr As String = &#8220;Provider=Microsoft.Jet.OLEDB.4.0;Data Source=&#8221; + filepath + filenameDim cnn As OleDbConnection = New OleDbConnection(cnnStr)Trycnn.Open()Catch ex As ExceptioncnnStr = &#8220;Provider=Microsoft.Jet.OLEDB.4.0;Data Source=&#8221; + filepath + filenamecnn = New OleDbConnection(cnnStr)cnn.Open()End Try Dim ConnectionString As String = &#8220;Trusted_Connection=no;Server=AMAZONA-RPKEMQI;Database=ContactManager;Uid=sa;Pwd=Sql12345;&#8221;Dim Accesscmd As New OleDbCommandAccesscmd.Connection = cnn&#8217;Acces Dan J vb.net extension-methods When [&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-3781","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/3781","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=3781"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/3781\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=3781"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=3781"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=3781"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}