What to do with error “You don’t have permission to open this file”. VB.Net express edition

If you are using Visual Basic 2010 Express, you may see the error message above when you try to connect to a database. An easy way to fix this problem (but not the only way) is to use the Browse button in the Add Connection dialog box shown below, navigate to the DATA directory for SQL Server on your hard drive (see the location near the bottom of page 2 of this document), and select the particular database.mdf file.


VB.Net code for preventing duplicate entry in a ComboBox? Vb.Net code for beginners

Sometime when we are entering list of items and list of departments in a combobox and when the list which we are entering is longer then there is chances that some of the items we entered in list box may be duplicate or we can say a double entry of same items may be made. So now the question arises how to to prevent such entries at the time of making it. We can prevent such entry with this vb.net code

Private Sub  BtnAddDep_Click(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles BtnAddDep.Click
'Add department text property to ComboBox listing
Dim FBoolean As Boolean = False
 Dim IndInteger As Integer = 0
Do Until FBoolean = True Or IndInteger =
If DepComboBox.Text.Trim.ToUpper =
DepComboBox.Items(IndInteger).ToString.Trim.ToUpper Then
FBoolean = True
'Add 1 to index value
IndInteger += 1
End If
Loop 'Loop back and try again
'Now decide whether to add item or not
If FBoolean = False And DepComboBox.Text.Trim
<> String.Empty Then
MessageBox.Show("Duplicate or Invalid Department Name", "Duplicate Data
Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
End If
End Sub


What would cause DSL light to be on and internet light to be off? DSL on & internet Light off.

 Binatone DT845W modem
During last September 2012 , I have bought a Broadband  ADSL + wifi modem of Binatone compnay. The model no of my modem is Binatone DT845W and got it configured with BSNL Broad band connection. For two three days, it worked very fine but after that frequently its internet light got off sometime due to sudden power failure or sometimes without any reason. I got fed up with as I several times called BSNL people, they come and check their phone line and broadband setting and all the times they found everything fine but even then my modem internet light is not On, I did many R&D on my modem like when I repeatedly make power supply switch on-off, on-off it get working some times not.

How to make user id and password case sensitive ? VB.Net Code for beginners

After developing a software we try many things to make the software security proof and in that process we can try to make the user id and password case sensitive. for doing this these are the VB.Net code which I used in my program and it is working fine.

Imports System.Data.OleDb
Imports System.IO
Public Class FrmLogin
    Inherits System.Windows.Forms.Form
    Dim cn As New OleDbConnection
    Dim cmd As New OleDb.OleDbCommand
    Public LoginSucceeded As Boolean
    Dim Counter As Integer
    Dim bm As BindingManagerBase
    Private Sub FrmLogin_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        cn.ConnectionString = Moduledatasource
        LoginSucceeded = False
    End Sub

    Private Sub BtnOk_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnOk.Click
            If Counter = 8 Then
                MsgBox("You have exceeded the number of attempts")
                Exit Sub
            End If
            If TxtUserId.Text = "" Or TxtPassword.Text = "" Then
                MsgBox("You must enter a user name and password.", _
                vbOKOnly + vbInformation)


                Dim CmdER As New OleDbCommand
                Dim MyReader As OleDb.OleDbDataReader
                CmdER.Connection = cn
                CmdER.CommandText = "Select * from UserAccount where UserId = '" & TxtUserId.Text & " 'and UserPassword =  '" & TxtPassword.Text & "'"
                MyReader = CmdER.ExecuteReader

                If MyReader.Read() Then
                    'to make the User Id and Password case snsitive
                    If TxtPassword.Text <> MyReader("UserPassword").ToString Or TxtUserId.Text <> MyReader("UserId").ToString Then
                        MessageBox.Show(" User ID and Password is case sensitive. Login Denied ", " Error! ", MessageBoxButtons.OK, MessageBoxIcon.Error)
                        TxtPassword.Text = ""

                        TxtUserAccount.Text = MyReader("AccountType")
                        If TxtUserAccount.Text = "A" Then
                            FrmMainMDI.DataBackupToolStripMenuItem.Enabled = True
                            FrmMainMDI.UtilityToolStripMenuItem.Enabled = False
                            FrmMainMDI.PrintToolStripMenuItem.Enabled = False
                            FrmMainMDI.ReportToolStripMenuItem.Enabled = False
                        End If
                    End If

                    MsgBox("Your user ID or Password is wrong")
                    TxtPassword.Text = ""
                    TxtUserId.Text = ""
                End If
                LoginSucceeded = True
            End If

        Catch ex As Exception
            Dim MessageString As String = "Report this error to the system administrator: " & ControlChars.NewLine & ex.Message
            Dim TitleString As String = "Employee Master Details Data Load Failed"
            MessageBox.Show(MessageString, TitleString, MessageBoxButtons.OK, MessageBoxIcon.Error)
        End Try
    End Sub 
The above code is to check the user id case sensitivity and also type of user like admin or normal. Please comment your view.


How to restrict number of digits after decimal? VB.Net code for beginners!

Restricting the numbers of digit after decimal is very small code but it has very important role in coding for any program specially related in mathematical calculation and also in financial programming. Suppose one wants to divide 5 by 9 the correct answer will .55555555555555........ and if he wants to restrict the 2 or 4 digits after decimal then the answer will be .55 or .5555.
To achieve this result the VB.Net code will be " Math.Round(result, number of digits)"
            Dim percent, row, counter As Double

            percent = val(txtNo1.text)
            counter = val(txtNo2.text)
            row = counter / percent
            Label12.Text = Math.Round(row, 2)

The above code will restrict the  2 digits after decimal and if one wants to increase the number of digits after decimal just change the 2 to any integer number.