VB.NET:
[COLOR=#00007f]Imports[/COLOR] System.Data.OleDb
[COLOR=#00007f]Public[/COLOR] [COLOR=#00007f]Class[/COLOR] AddCustomerForm
[COLOR=#00007f]Inherits[/COLOR] System.Windows.Forms.Form
[COLOR=#00007f]Dim[/COLOR] cn [COLOR=#00007f]As[/COLOR] OleDbConnection
[COLOR=#00007f]Dim[/COLOR] cmd [COLOR=#00007f]As[/COLOR] OleDbCommand
[COLOR=#00007f]Dim[/COLOR] dr [COLOR=#00007f]As[/COLOR] OleDbDataReader
[COLOR=#00007f]Dim[/COLOR] icount [COLOR=#00007f]As[/COLOR] [COLOR=#00007f]Integer[/COLOR]
[COLOR=#00007f]Dim[/COLOR] str [COLOR=#00007f]As[/COLOR] [COLOR=#00007f]String[/COLOR]
[COLOR=#00007f]Private[/COLOR] [COLOR=#00007f]Sub[/COLOR] AddOKBtn_Click([COLOR=#00007f]ByVal[/COLOR] sender [COLOR=#00007f]As[/COLOR] System.[COLOR=#00007f]Object[/COLOR], [COLOR=#00007f]ByVal[/COLOR] e [COLOR=#00007f]As[/COLOR] System.EventArgs) [COLOR=#00007f]Handles[/COLOR] AddOKBtn.Click
[COLOR=#00007f]Try[/COLOR]
cn = [COLOR=#00007f]New[/COLOR] OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=AccessDB.mdb;")
cn.[COLOR=#00007f]Open[/COLOR]()
str = "INSERT INTO Customer Values(" & [COLOR=#00007f]CInt[/COLOR](txtID.Text) & ",'" & txtFirstName.Text & "','" & txtLastName.Text & "','" & txtDetails.Text & "','" & txtReceipt.Text & "[COLOR=#007f00]');"
[/COLOR] cmd = [COLOR=#00007f]New[/COLOR] OleDbCommand(str, cn)
[COLOR=#00007f]Catch[/COLOR]
[COLOR=#00007f]End[/COLOR] [COLOR=#00007f]Try[/COLOR]
cn.[COLOR=#00007f]Close[/COLOR]()
[COLOR=#00007f]Me[/COLOR].Hide()
[COLOR=#00007f]End[/COLOR] [COLOR=#00007f]Sub[/COLOR]
ps. my datagridview is on a different form from the input controls
mainform > add button > add input controls
I've tried another code
VB.NET:
Public Class AddCustomerForm
Private Sub AddOKBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AddOKBtn.Click
Dim newCustomerRow As AccessDBDataSet.CustomerRow
newCustomerRow = AccessDBDataSet.Customer.NewCustomerRow()
newCustomerRow.ID = txtID.Text
newCustomerRow.FirstName = txtFirstName.Text
newCustomerRow.LastName = txtLastName.Text
newCustomerRow.Details = txtDetails.Text
newCustomerRow.Receipt = txtReceipt.Text
AccessDBDataSet.Customer.Rows.Add(newCustomerRow)
AccessDBDataSet.Customer.AcceptChanges()
MainForm.CustomerTableAdapter.Fill(MainForm.AccessDBDataSet.Customer)
Me.Hide()
End Sub
but this only fills the add form with the new data