Dim con As New OleDb.OleDbConnection Dim dbProvider As String Dim dbSource As String Dim ds As New DataSet Dim da As OleDb.OleDbDataAdapter Dim sql As String Dim inc As Integer dbProvider = "provider=microsoft.ACE.OLEDB.12.0;" dbSource = "DATA SOURCE=C:\cwhData\cwhData.accdb" con.ConnectionString = dbProvider & dbSource con.Open() sql = "select * from customer" da = New OleDb.OleDbDataAdapter(sql, con) If inc <> -1 Then Dim cb As New OleDb.OleDbCommandBuilder(da) Dim dsNewRow As DataRow dsNewRow = ds.Tables("customer").NewRow() dsNewRow.Item("CUSTOMERID") = txtCustomerID.Text dsNewRow.Item("customername") = txtCustomerName.Text ds.Tables("customer").Rows.Add(dsNewRow) da.Update(ds, "customer") MsgBox("New record added to the database") End If MsgBox("database is now open") con.Close() MsgBox("database is now closed") End Sub
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)