使用以下代码,我只是尝试获取文本框(txtResult.Text)的值并将该值插入Access数据库表中。该代码运行没有错误,只是填充到表中的值为-1而不是预期的字符串值(例如5 + 5 = 10)。有帮助吗?
Dim con As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Marcus\Desktop\ENTD461Week6.accdb")
Dim cmd As New OleDbCommand
Dim var1 As String
con.Open()
cmd.Connection = con
Try
listOperations.Add(txtResult.Text)
listNumber1.Add(Val(txtNo1.Text))
listNumber2.Add(Val(txtNo2.Text))
var1 = txtResult.Text
cmd.CommandText = ("INSERT into tblExpressions (Expressions) VALUES(" + var1 + ")")
cmd.ExecuteNonQuery()
Catch ex As Exception
MsgBox(ex.Message)
End Try