0% found this document useful (0 votes)
5 views

vb.net database solve slip program

The document contains multiple VB.NET program snippets for various tasks including creating and manipulating database tables for teachers, departments, and movies. It demonstrates how to insert, update, and delete records from these tables using OleDb connections. Additionally, it includes an ASP.NET program that changes a button's color on mouse hover.

Uploaded by

Muktar Fakir
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

vb.net database solve slip program

The document contains multiple VB.NET program snippets for various tasks including creating and manipulating database tables for teachers, departments, and movies. It demonstrates how to insert, update, and delete records from these tables using OleDb connections. Additionally, it includes an ASP.NET program that changes a button's color on mouse hover.

Uploaded by

Muktar Fakir
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Slip 3 B) Write a vb.

net program to create teacher table (Tid, Tname, subject)


Insert the records. Search record of teacher whose name is “seeta” and display
result.
ImportsSystem.Data.OleDb
PublicClassForm1
DimcnAsOleDbConnection
DimcmdAsOleDbCommand
DimdrAsOleDbDataReader
DimicountAsInteger
DimstrAsString
Dim str1 AsString
Dim cmd1 AsOleDbCommand
Dim adpt1 AsOleDbDataAdapter
Dim ds As New DataSet
PrivateSub Form1_Load(ByVal sender AsSystem.Object, ByVal e AsSystem.EventArgs)
HandlesMyBase.Load
Me.Techer1TableAdapter.Fill(Me.TeacherDataSet.techer1)

EndSub

PrivateSub Button1_Click(ByVal sender AsSystem.Object, ByVal e


AsSystem.EventArgs) Handles Button1.Click
cn = NewOleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0; Data Source= C:\
teacher.mdb")
cn.Open()
str = "insert into techer1 values("&CInt(TextBox1.Text) &",'"& TextBox2.Text
&"'"&",'"& TextBox3.Text &"')"
cmd = NewOleDbCommand(str, cn)
icount = cmd.ExecuteNonQuery
MessageBox.Show(icount&"Row inserted")

adpt1 = NewOleDbDataAdapter("select * from techer1 where tname='patil'",


cn)
adpt1.Fill(ds, "st")
DataGridView1.DataSource = ds
DataGridView1.DataMember = "st"
MessageBox.Show("Record found")
cn.Close()
EndSub
EndClass
Slip 4 B)Create a web application to insert 3 records inside the SQL database
table having
following fields ( DeptId, DeptName, EmpName, Salary). Update the salary for any
one
employee and increment it to 15% of the present salary.

PublicClassForm1
Dim con AsNewOleDb.OleDbConnection
Dim da AsNewOleDb.OleDbDataAdapter
Dim ds AsNewDataSet
DimcmdAsNewOleDb.OleDbCommand
Dim query AsString
DimdbProviderAsString
DimdbSourceAsString
PrivateSub Form1_Load(ByVal sender AsSystem.Object, ByVal e AsSystem.EventArgs)
HandlesMyBase.Load
Me.StudTableAdapter.Fill(Me.StudentmdbDataSet.dept)
dbProvider = "PROVIDER=Microsoft.Jet.OLEDB.4.0;"
dbSource = "Data Source=C:\studentmdb.mdb"
con.ConnectionString = dbProvider&dbSource
con.Open()
da = NewOleDb.OleDbDataAdapter("select * from dept", con)
da.Fill(ds, "dt")
DataGridView1.DataSource = ds.Tables("dt")
EndSub

PrivateSub Button1_Click(ByVal sender AsSystem.Object, ByVal e


AsSystem.EventArgs) Handles Button1.Click
Dim x AsInteger
query = "update dept set salary='abc' where salary=salary+(salary*15)"

cmd = NewOleDb.OleDbCommand(query, con)


Try
x = cmd.ExecuteNonQuery()
If (x) Then
MsgBox("Data Updated")
Else
MsgBox("No data to update")
EndIf
ds.Tables.Clear()
da = NewOleDb.OleDbDataAdapter("select * from dept", con)
da.Fill(ds, "dt")
DataGridView1.DataSource = ds.Tables("dt")
Catch ex AsException
MsgBox("Exception Occured")

EndTry
EndSub
EndClass
// slip 6 B) Write a VB.NET program to create movie table (Mv_Name, Release_year,
Director). Insert the records (Max: 5). Delete the records of movies whose release year is
2022 and display appropriate message in message box. [25 M]

Public Class Form1


Dim con As New OleDb.OleDbConnection
Dim ds As New DataSet
Dim da As New OleDb.OleDbDataAdapter
Dim cmd As New OleDb.OleDbCommand

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles


MyBase.Load
con.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\Ramdas\
Documents\auth.mdb"
con.Open()
da = New OleDb.OleDbDataAdapter("select * from movie", con)
da.Fill(ds, "mv")
GridView1.DataSource = ds.Tables("mv")
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles


Button2.Click
Dim q As String
Dim x As Integer
q = "delete from movie where Release_year='2022'"
cmd = New OleDb.OleDbCommand(q, con)
Try
x = cmd.ExecuteNonQuery()
If (x) Then
MsgBox("Data Deleted")
Else
MsgBox("Data not deleted")
End If
ds.Tables.Clear()

da = New OleDb.OleDbDataAdapter("select * from movie", con)


da.Fill(ds, "mv")
GridView1.DataSource = ds.Tables("mv")
Catch ex As Exception
MsgBox("Exception Occured")
End Try
End Sub

End Class

//slip12 A)
Slip 12 A) Write ASP.Net program that displays a button in green color and it should change

into yellow when the mouse moves over it.

Public Class Form1

Private Sub Button1_MouseHover(ByVal sender As Object, ByVal e As


System.EventArgs) Handles Button1.MouseHover
Button1.BackColor = Color.Yellow
End Sub

Private Sub Button1_MouseLeave(ByVal sender As Object, ByVal e As


System.EventArgs) Handles Button1.MouseLeave
Button1.BackColor = Color.Green
End Sub

End Class

You might also like