如何将串口接收到的数据存入数据库? 数据怎么转换?

2025-01-26 16:18:20
推荐回答(2个)
回答1:

工程->引用->Microsoft ActiveX Data Objects 2.5 Library
表名 b,字段c

Private Sub Command1_Click()
Dim cnDk As New ADODB.Connection
Dim strDk As String
Dim rDk As New ADODB.Recordset
Dim sql As String

strDk = "driver=;server=(local);uid=sa;pwd=123456;database=a" '这个字符串要改成你需要的
' 上有各种连接字符串的查询
cnDk.Open strDk
sql = "insert into b (c) values ('" & text1.text & "')"
cnDk.Execute sql
cnDk.Close
Set cnDk = Nothing
End Sub

回答2:

工程->引用->Microsoft ActiveX Data Objects 2.5 Library
表名 b,字段c

Private Sub Command1_Click()
Dim cnDk As New ADODB.Connection
Dim strDk As String
Dim rDk As New ADODB.Recordset
Dim sql As String

strDk = "driver=;server=(local);uid=sa;pwd=123456;database=a" '这个字符串要改成你需要的
' 上有各种连接字符串的查询
cnDk.Open strDk
sql = "insert into b (c) values ('" & text1.text & "')"
cnDk.Execute sql
cnDk.Close
Set cnDk = Nothing
End Sub
另外,虚机团上产品团购,超级便宜