This page covers NET Practical Slip 3 Q B, featuring key .NET programming exercises and essential viva questions to help students prepare for practical exams and strengthen their understanding of core .NET concepts such as inheritance, class structure, and string handling.
Slip 3 Q.B) Write a VB.NET program to create a teacher table (Tid, TName, subject). Insert the records (Max: 5). Search for a teacher whose name is “Seeta” and display the result. 25 Marks
Answer:
Source Code
Imports System
Imports System.Data
Imports System.Data.OleDb
Public Class Form1
Dim con As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Saurabh\Desktop\New folder\teacher.accdb")
Dim adpt As New OleDbDataAdapter("Select * from teacher", con)
Dim cmd As New OleDbCommand
Dim ds As New DataSet
Public Function display()
adpt.Fill(ds, "teacher")
DataGridView1.DataSource = ds
DataGridView1.DataMember = "teacher"
Return ds
End Function
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
display()
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
cmd.Connection = con
cmd.CommandType = CommandType.Text
cmd.CommandText = "insert into teacher values(" & TextBox1.Text & ",'" & TextBox2.Text & "','" & TextBox3.Text & "')"
con.Open()
If cmd.ExecuteNonQuery() Then
MessageBox.Show("Inserted Successfully...!")
End If
con.Close()
ds.Clear()
display()
End Sub
Private Sub TextBox4_KeyDown(sender As Object, e As KeyEventArgs) Handles TextBox4.KeyDown
ds.Clear()
Dim adp As New OleDbDataAdapter("select * from teacher Where Name like '%" & TextBox4.Text & "%'", con)
adp.Fill(ds, "search")
DataGridView1.DataSource = ds
DataGridView1.DataMember = "search"
End Sub
End Class
FAQ Section
Q1. What is the .NET Framework and why is it used in application development?
A software framework by Microsoft that provides tools, libraries, and runtime for building and running applications.
Q2. Define a class in C#.
A blueprint for objects that defines properties and methods.
Q3. What is inheritance in .NET and how does it help in programming?
Mechanism where a class derives from another class to reuse code and extend functionality.
Q4. What is the difference between public and private access modifiers?public allows access from outside the class; private restricts access to within the class only.
Q5. Explain how to reverse a string in C# (mention any method or logic).
You can use Array.Reverse() on the character array or a for loop to build a reversed string.