Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim constr As String = "provider=microsoft.ace.oledb.12.0 ; data source = d:\testdata.accdb"
Dim con As New OleDbConnection(constr)
con.Open()
Dim sql As String = "insert into newtest(bookname) values(@bookname)"
Dim cmd As New OleDbCommand(sql, con)
Dim i As Integer
For i = 0 To ListBox1.Items.Count - 1
cmd.Parameters.AddWithValue("bookname", ListBox1.Items.Item(i))
cmd.ExecuteNonQuery()
Next
MsgBox("บันทึกข้อมูลเรียบร้อย", MsgBoxStyle.OkOnly, "บันทึกข้อมูล")
con.Close()
End Sub
End Class
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim constr As String = "provider=microsoft.ace.oledb.12.0 ; data source = d:\testdata.accdb"
Dim con As New OleDbConnection(constr)
con.Open()
Dim sql As String = "insert into newtest(bookname) values(@bookname)"
Dim cmd As New OleDbCommand(sql, con)
Dim i As Integer
For i = 0 To ListBox1.Items.Count - 1
cmd.Parameters.AddWithValue("bookname", ListBox1.Items.Item(i))
Next
cmd.ExecuteNonQuery()
MsgBox("บันทึกข้อมูลเรียบร้อย", MsgBoxStyle.OkOnly, "บันทึกข้อมูล")
con.Close()
End Sub
End Class