列表框到Access数据库

时间:2013-12-30 17:23:20

标签: database vb.net listbox

到目前为止,我有这个,这是行不通的。我想我走错了路。基本上我正在尝试将列表框的所有项目传输到名为CalcOps的Access数据库的单独列,其中包含“NumOne,Operator,NumTwo,Result”列。列表框当前可以包含10个列表项,单击按钮时,所有这些都应该被传输(ButtonDBSave)。列表框项目从单独的文本框放在一起,单击的操作符通过Listbox.tag传输到列表框。没有任何错误..或其他任何东西。

Private Sub ButtonDBSave_Click(sender As Object, e As EventArgs) Handles ButtonDBSave.Click


    Dim con As New OleDb.OleDbConnection
    Dim dbProvider As String
    Dim dbSource As String

    dbProvider = "Provider=Microsoft.ACE.OLEDB.12.0"
    dbSource = "Data Source=|DataDirectory|\CalcDB.accdb"

    con.ConnectionString = dbProvider & dbSource


    Dim arr As New List(Of String)
    Dim cmdText As String = "INSERT INTO NumOne ()"
    Dim cmd As OleDb.OleDbCommand = New OleDb.OleDbCommand(cmdText)
    cmd.CommandType = CommandType.Text

    con.Open()

    With cmd.Parameters
        .Add("@NumOne", OleDb.OleDbType.VarChar).Value = NumOne.Text


    End With


End Sub

0 个答案:

没有答案