我有一个按钮" btnSetAppointment",我创建了一个调度系统,当我保存约会时,它会自动向患者发送一条消息phone_number
。但是,我不知道如何从表格中获取phone_number
的价值。
如下所示,我将number声明为字符串,我想将患者的phone_number
存储在数据库中。
Private Sub btnSetAppointment_Click(sender As Object, e As EventArgs) Handles btnSetAppointment.Click
'SMS
query = "SELECT * FROM schedule WHERE Phone_Number =" & frmViewSchedule.dgvSchedule.SelectedRows(3).Cells(0).Value
cmd = New MySqlCommand(query, MySqlConn)
reader = cmd.ExecuteReader
Dim number1 As String
If reader.HasRows Then
number1 = frmViewSchedule.dgvSchedule.SelectedRows(3).Cells(0).Value
With SerialPort1
.Write("at" & vbCrLf)
Threading.Thread.Sleep(1000)
.Write("at+cmgf=1" & vbCrLf)
Threading.Thread.Sleep(1000)
.Write("at+cmgs=" & Chr(34) & number1 & Chr(34) & vbCrLf)
.Write(sys_msg & Chr(26))
Threading.Thread.Sleep(1000)
MsgBox(rcvdata.ToString)
End With
End If
end sub
答案 0 :(得分:0)
这就是我使用MySQL(建立数据库连接后)的方法。
{{1}}