01.
Protected
Sub
Button1_Click(sender
As
Object
, e
As
EventArgs)
Handles
Button1.Click
02.
Dim
objConn
As
New
MySqlConnection
03.
Dim
objCmd
As
New
MySqlCommand
04.
Dim
strConnString, strSQL
As
String
05.
06.
07.
08.
strConnString =
"Server=localhost;User Id=root; Password=1234; Database=feederphone; Pooling=false"
09.
10.
strSQL =
"INSERT INTO feeder_sched (hour_1,min_1,hour_2,min_2,hour_3,min_3,weight_1,weight_2,weight_3,KeyID) "
& _
11.
" VALUES "
& _
12.
" ('"
&
Me
.Hour1.Text &
"','"
&
Me
.Min1.Text &
"', "
& _
13.
" '"
&
Me
.Hour2.Text &
"','"
&
Me
.Min2.Text &
"','"
&
Me
.Hour3.Text &
"','"
&
Me
.Min3.Text &
"','"
&
Me
.weight1.Text &
"','"
&
Me
.weight2.Text &
"','"
&
Me
.weight3.Text &
"','"
& &
"')"
14.
objConn.ConnectionString = strConnString
15.
objConn.Open()
16.
17.
With
objCmd
18.
.Connection = objConn
19.
.CommandText = strSQL
20.
.CommandType = CommandType.Text
21.
End
With
22.
23.
24.
25.
Try
26.
objCmd.ExecuteNonQuery()
27.
MsgBox(
"Saved"
)
28.
Catch
ex
As
Exception
29.
MsgBox(
"Error"
)
30.
31.
End
Try
32.
33.
objConn.Close()
34.
objConn =
Nothing
35.
36.
End
Sub
37.
38.
Protected
Sub
Button2_Click(sender
As
Object
, e
As
EventArgs)
Handles
Button2.Click
39.
Dim
objConn
As
New
MySqlConnection
40.
Dim
objCmd
As
New
MySqlCommand
41.
Dim
strConnString, strSQL
As
String
42.
43.
strConnString =
"Server=localhost;User Id=root; Password=1234; Database=feederphone; Pooling=false"
44.
45.
strSQL =
"UPDATE feederphone.feeder_sched SET hour_1='"
& Hour1.Text &
"',min_1='"
& Min1.Text &
"',hour_2='"
& Hour2.Text &
"',min_2='"
& Min2.Text &
"',hour_3='"
& Hour3.Text &
"',min_3='"
& Min3.Text &
"',weight_1='"
& weight1.Text &
"',weight_2='"
& weight2.Text &
"',weight_3='"
& weight3.Text &
"',KeyID='"
& IDM.Text &
"' WHERE KeyID = '"
& IDM.Text &
"'"
46.
objConn.ConnectionString = strConnString
47.
objConn.Open()
48.
49.
With
objCmd
50.
.Connection = objConn
51.
.CommandText = strSQL
52.
.CommandType = CommandType.Text
53.
End
With
54.
55.
56.
57.
Try
58.
objCmd.ExecuteNonQuery()
59.
MsgBox(
"Saved"
)
60.
Catch
ex
As
Exception
61.
MsgBox(
"Error"
)
62.
63.
End
Try
64.
65.
objConn.Close()
66.
objConn =
Nothing
67.
68.
End
Sub