-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathForm3.vb
54 lines (49 loc) · 1.81 KB
/
Form3.vb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
Imports MySql.Data.MySqlClient
Public Class Form3
Dim mysqlcon As MySqlConnection
Dim cmd As MySqlCommand
Dim reader As MySqlDataReader
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
home.Show()
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Dim constr As String = "Database=vb;" & _
"Data Source=localhost;" & _
"User Id=root;Password="
mysqlCon = New MySqlConnection(constr)
Try
mysqlCon.Open()
'MessageBox.Show("connection is ok")
Dim sql As String = "SELECT * FROM student"
cmd = New MySqlCommand(sql, mysqlCon)
reader = cmd.ExecuteReader
'reader.Read()
'MsgBox((reader.GetString(0) & ", " & reader.GetString(1) & "," & reader.GetString(2)))
'reader.Close()
Catch ex As MySqlException
MsgBox("failed to connect", MsgBoxStyle.Exclamation, ex.Message)
Finally
mysqlcon.Dispose()
End Try
End Sub
Private Sub DataGridView1_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles DataGridView1.CellContentClick
reader.Read()
MsgBox((reader.GetString(0) & ", " & reader.GetString(1) & "," & reader.GetString(2)))
reader.Close()
End Sub
Private Sub btnf_Click(sender As Object, e As EventArgs) Handles btnf.Click
End Sub
Function fa(ByVal x As Integer) As Integer
Dim result As Integer
If (x = 1) Then
Return 1
Else
result = fa(x - 1) * x
Return result
End If
End Function
Sub main()
fa(7)
MsgBox(fa(6))
End Sub
End Class