Dot Net Framework
A)
Write a VB.Net Program to display the numbers continuously in TextBox by
clicking
on Button.
Answer :
Public Class Form1
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
TextBox1.Text =
Second(DateTime.Now)
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Timer1.Enabled = True
Timer1.Interval =
1000
Timer1.Start()
End Sub
End Class
Output :
B)
Write a VB.Net program to accept the details of Employee (ENO, EName Salary)
and
store it into the database and display it on gridview control.
Answer :
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\Desktop\New folder\Emp.accdb")
Dim adpt As New OleDbDataAdapter("Select
* from Emp", con)
Dim ds As New DataSet
Dim cmd As New OleDbCommand
Public Function display()
adpt.Fill(ds, "Emp")
DataGridView1.DataSource = ds
DataGridView1.DataMember = "Emp"
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 Emp values(" & TextBox1.Text & ",'" & TextBox2.Text & "'," & TextBox3.Text & ")"
con.Open()
cmd.ExecuteNonQuery()
con.Close()
ds.Clear()
display()
End Sub
End Class
Output :
No comments:
Post a Comment