VB .NET

VB .NET

Slip29

Q.1) Write a VB.NET program to create Author table (aid , aname , book_name). Insert the records (Max 5). Delete a record of author who has written “VB.NET book” and display remaining records on the Crystal Report.(Use MS Access to create db)  [Marks 20] 

Solution

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 auther", con)
da.Fill(ds, "ath")
DataGridView1.DataSource = ds.Tables("ath")
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 auther where bname='VB.NET'"
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 auther", con)
da.Fill(ds, "ath")
DataGridView1.DataSource = ds.Tables("ath")
Catch ex As Exception
MsgBox("Exception Occured")
End Try
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Form2.Show()
End Sub
End Class
BCA Pratical Solution

My name is Vivek And I from Mumbai and Complete my Graduation Bca.my Age is 23 Years.

Post a Comment

Previous Post Next Post