Home > Net >  "Private Sub Button1_Click (sender As Object, e the As System. EventArgs)" there are multi
"Private Sub Button1_Click (sender As Object, e the As System. EventArgs)" there are multi

Time:11-20

Imports System. The Data. SqlClient 'add reference namespace
Public Class Tadd
Dim connstr As String=(" Data Source=LAPTOP - IVGA33CA; Initial Catalog=JXGL; Integrated Security=True ") to establish a connection
Dim conn As New SqlClient. SqlConnection (connstr)
Private Sub Button1_Click (ByVal sender As System. Object, ByVal e the As System. EventArgs) Handles for. Click
Dim insertsql As String="insert into the T (t# tnametssex, tbirthin, titleof, trsection, tel)"
Dim CMD As New SqlClient. SqlCommand (insertsql, conn.)
'check to add teachers, whether there is
Dim sqlstring As String="select * from T where t#='" & amp; TextBox1. Text & amp; "'
"Conn. The Open ()
Dim com2 As New SqlClient. SqlCommand (sqlstring, conn.)
Dim read1 As SqlDataReader=com2. ExecuteReader
Then If read1. Read ()
MsgBox (" no. The teacher has been in existence!" , MsgBoxStyle. Information, hint! "" )
TextBox1. Text=""
TextBox2. Text=""
ComboBox1. Text="male"
DateTimePicker1. Value="https://bbs.csdn.net/topics/1965/12/31"
ComboBox2. Text=""
ComboBox3. Text=""
TextBox3. Text=""
ElseIf TextBox1. Text="" Then
MsgBox (" please enter the number teachers!" , MsgBoxStyle. Information, hint! "" )
ElseIf TextBox2. Text="" Then
MsgBox (" please input your name!" , MsgBoxStyle. Information, hint! "" )

The Else
'add a new teachers' information
Conn. Close ()
CMD. The Parameters. The Add (" @ T# ", SqlDbType. VarChar). The Value=https://bbs.csdn.net/topics/TextBox1.Text
CMD. The Parameters. The Add (" @ tname ", SqlDbType. VarChar). The Value=https://bbs.csdn.net/topics/TextBox2.Text
CMD. The Parameters. The Add (" @ tsex ", SqlDbType. VarChar). The Value=https://bbs.csdn.net/topics/ComboBox1.Text
CMD. The Parameters. The Add (" @ tbirthin ", SqlDbType. VarChar). The Value=https://bbs.csdn.net/topics/DateTimePicker1.Value
CMD. The Parameters. The Add (" @ titleof ", SqlDbType. VarChar). The Value=https://bbs.csdn.net/topics/ComboBox2.Text
CMD. The Parameters. The Add (" @ trsection ", SqlDbType. VarChar). The Value=https://bbs.csdn.net/topics/ComboBox3.Text
CMD. The Parameters. The Add (" @ tel, SqlDbType. VarChar). The Value=https://bbs.csdn.net/topics/TextBox3.Text
Conn. The Open ()
CMD. ExecuteNonQuery ()
MsgBox (" teachers information add success!" , MsgBoxStyle. Information, hint! "" )
End the If
TextBox1. Text=""
TextBox2. Text=""
ComboBox1. Text="male"
DateTimePicker1. Value="https://bbs.csdn.net/topics/1965/12/31"
ComboBox2. Text=""
ComboBox3. Text=""
TextBox3. Text=""
Conn. Close ()
End Sub

Private Sub Button2_Click (sender As Object, As EventArgs e) Handles Button2. Click
Me. The Close ()
End Sub

Private Sub Button1_Click (sender As Object, As EventArgs e) Handles for. Click

End Sub
The End of the Class

CodePudding user response:

Search the Button1_Click, multiple functions

CodePudding user response:

Your code to the last paragraph, the definition of a set of the Button1_Click more,

CodePudding user response:

The last Private Sub Button1_Click (sender As Object, As EventArgs e) Handles for. Click the delete
  • Related