Imports System.Data.OleDb ' Use System.Data.SqlClient for SQL Server Public Class LoginForm Dim conn As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\DB\Users.accdb") Private Sub btnLogin_Click(sender As Object, e As EventArgs) Handles btnLogin.Click conn.Open() Dim cmd As New OleDbCommand("SELECT * FROM Users WHERE Username='" & txtUser.Text & "' AND Password='" & txtPass.Text & "'", conn) Dim dr As OleDbDataReader = cmd.ExecuteReader() If dr.Read() Then MessageBox.Show("Login Successful") Else MessageBox.Show("Invalid Credentials") End If conn.Close() End Sub End Class Use code with caution. Part 2: Common VB.NET Lab Program Fixes & Debugging
The you are connecting to, if applicable (MS Access, SQL Server, etc.)
When using MessageBox.Show() for errors, tell the user what went wrong and how to fix it. “Error” is not helpful. “Please enter a positive number” is helpful.
Remember: Every error you encounter is a learning opportunity. The VB.NET errors that confuse you today will become patterns you recognize instantly tomorrow. The key is to stop guessing and start debugging systematically.
Before diving into fixes, it helps to know what’s typically expected. A standard BCA VB.NET lab syllabus usually covers:
These focus on VB.NET syntax, data types, and control structures. Jayoti Vidyapeeth Women's UniversitY (JVWU) Arithmetic Calculator : Perform basic operations ( Greatest of Three Numbers If...ElseIf blocks to find the maximum value. Leap Year Check : Determine if a user-input year is a leap year. Vowel or Consonant : Check a character using a Select Case statement. Factorial Calculation : Implement using a For...Next Fibonacci Series : Generate the series up to 2. Windows Form Controls & UI Events
Use the Debug.WriteLine() method to write diagnostic messages to the Output window during runtime without interrupting execution. This is invaluable for tracking program flow.