Imports System.Data.
SqlClient
Public Class Form1
Dim con As New SqlConnection("Integrated Security=SSPI;Persist Security
Info=False;Initial Catalog=student study;Data Source=DESKTOP-A5IN5UO\SQLEXPRESS")
Dim cmd As New SqlCommand("select * from study", con)
Dim dt As New DataTable
Dim da As New SqlDataAdapter(cmd)
Dim df As New SqlCommandBuilder(da)
Dim mx As Double = 0
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
End Sub
///////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////
��� ���
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
If con.State = Data.ConnectionState.Closed Then con.Open()
If TextBox1.Text = "" Or TextBox2.Text = "" Or TextBox3.Text = "" Or
TextBox4.Text = "" Then
MsgBox("������ ����� ������")
Exit Sub
End If
Dim cmd As New SqlCommand("insert into study values(" & Val(TextBox1.Text)
& ",'" & Trim(TextBox2.Text) & "','" & Trim(TextBox3.Text) & "','" &
Trim(TextBox4.Text) & "')", con)
cmd.ExecuteNonQuery()
MsgBox("�� �����")
End Sub
///////////////////////////////////////////////////////////////////////////////////
/////////////
��� ���
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
If con.State = ConnectionState.Closed Then con.Open()
Dim b As Boolean = False
Dim cmd As New SqlCommand("select * from study where id=" &
Val(TextBox1.Text) & "", con)
Dim dr As SqlDataReader
dr = cmd.ExecuteReader
While dr.Read
TextBox2.Text = dr(1)
TextBox3.Text = dr(2)
TextBox4.Text = dr(3)
b = True
End While
dr.Close()
If b = False Then
MsgBox("�������� ��� ������")
End If
End Sub
///////////////////////////////////////////////////////////////////////////////////
//////////////////////
��� �������
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button3.Click
If con.State = ConnectionState.Closed Then con.Open()
Dim cmd As New SqlCommand("update study set stu_nam='" &
Trim(TextBox2.Text) & "',adress='" & Trim(TextBox3.Text) & "',datee='" &
Trim(TextBox4.Text) & "'where id=" & Val(TextBox1.Text) & "", con)
cmd.ExecuteNonQuery()
MsgBox("�� ������� �����")
TextBox1.Clear()
TextBox2.Clear()
TextBox3.Clear()
TextBox1.Select()
End Sub
///////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////
��� �����
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button4.Click
If con.State = ConnectionState.Closed Then con.Open()
Dim cmd As New SqlCommand("delete from study where id=" &
Val(TextBox1.Text) & "", con)
cmd.ExecuteNonQuery()
MsgBox("�� ����� �����")
TextBox1.Clear()
TextBox2.Clear()
TextBox1.Select()
End Sub
///////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////
��� ����
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button5.Click
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox1.Focus()
End Sub
///////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////
�����
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button6.Click
Close()
End Sub
End Class