vb.netRelated issues-Collection of common programming errors


  • Dholakiya Ankit
    sql .net vb.net odbc ironspeed
    Dim cnnStr As String = “Provider=Microsoft.Jet.OLEDB.4.0;Data Source=” + filepath + filenameDim cnn As OleDbConnection = New OleDbConnection(cnnStr)Trycnn.Open()Catch ex As ExceptioncnnStr = “Provider=Microsoft.Jet.OLEDB.4.0;Data Source=” + filepath + filenamecnn = New OleDbConnection(cnnStr)cnn.Open()End Try Dim ConnectionString As String = “Trusted_Connection=no;Server=AMAZONA-RPKEMQI;Database=ContactManager;Uid=sa;Pwd=Sql12345;”Dim Accesscmd As New OleDbCommandAccesscmd.Connection = cnn’Acces

  • Dan J
    vb.net extension-methods
    When 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(“a”), New Foo(“b”), New Foo(“a”)}Dim i As Integer = l.Count(Function(foo) foo.Bar = “a”)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:’Public ReadOnly Propert

  • Heinzi
    c# java vb.net language-agnostic try-catch-finally
    I 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

  • mattmc3
    vb.net
    What are the pros and cons of standardizing on using Option Compare Text vs Option Compare Binary for VB.NET development?— EDIT —Just some background since it seems like it would help – 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’t found as easy to standardize on is Option Compare Text/Binary as there seem to be advantages and disadvantages to both a

  • Alex Essilfie
    vb.net casting directcast ctype
    Ever since I moved from VB6 to VB.NET somewhere in 2005, I’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

  • Marie J
    asp.net database vb.net visual-studio
    I 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’ve tried it several times so I am sure that is not the problem. I don’t want to return any results, I just want to see an “ok” statement if it runs and an error message if it doesn’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

  • devoured elysium
    c# .net vb.net bitmap equals
    From MSDN documentation, it seems as both GetHashCode() and Equals() haven’t been overriden in Bitmap. Neither have them been overriden in Image. So both classes are using the Object’s version of them just compares references. I wasn’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’t implement “comparison logic”, at least for the Bitmap class? I find it is kinda acceptable for Image, as i

  • Andrei
    asp.net html vb.net data-binding dataset
    Currently I am binding a dataset with a datagrid.ds = query.ExecuteReadQuery(“select PollQuestionText as ‘Survey Question’, PollAnswer1Text as ‘Selection 1’, PollAnswer2Text as ‘Selection 2’, PollAnswer3Text as ‘Selection 3’, PollEnabled ‘Status’ from tbl_pollquestions”)For Each row As Data.DataRow In ds.Tables(0).RowsIf row.ItemArray(4).ToString = “0” Thenrow.ItemArray.”<a href=””””> <img src=””img/box_icon_edit_pencil1.gif”” border=””0″”> </a>”ElseIf row.ItemArray(4).T

  • Tshepang
    vb.net excel exception popup alerts
    This 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’t found much. I’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

  • Cal
    asp.net vb.net loops foreach datatable
    I 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…I almost got it done the way I wanted, except that the result will be the same string repeated twice. For example, a string “abc” is what I want, but it will return “abcabc”.It’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,

Web site is in building