I tried to save/update my data from textbox to my access database. I don't know what wrong with my code. Nothing new record in my database, even though no error when i run my application.
Could somebody help me?
thanks
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim r As Data.DataRow
Me.OleDbConnection1.Open()
r = Me.CustomerDataset11.Tables("Customer").NewRow
Try
r.Item("Cust_ID") = Me.TextBox1.Text
r.Item("Address") = Me.TextBox3.Text
r.Item("City") = Me.TextBox4.Text
r.Item("State") = Me.TextBox5.Text
r.Item("Zip") = Me.TextBox6.Text
r.Item("Phone") = Me.TextBox7.Text
r.Item("Fax") = Me.TextBox8.Text
r.Item("Email") = Me.TextBox9.Text
r.Item("Type") = Me.TextBox10.Text
Me.CustomerDataset11.Tables("Customer").Rows.Add(r)
Try
Me.OleDbDataAdapter1.Update(Me.CustomerDataset11.GetChanges(DataRowState.Added))
Me.OleDbDataAdapter1.Update(Me.CustomerDataset11.GetChanges(DataRowState.Modified))
Me.CustomerDataset11.AcceptChanges()
Me.OleDbDataAdapter1.Fill(CustomerDataset11.Tables("Customer"))
Catch ex As Exception
End Try
Me.OleDbConnection1.Close()
Catch ex1 As Exception
Console.WriteLine(ex1.ToString())
End Try
End Sub
Could somebody help me?
thanks
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim r As Data.DataRow
Me.OleDbConnection1.Open()
r = Me.CustomerDataset11.Tables("Customer").NewRow
Try
r.Item("Cust_ID") = Me.TextBox1.Text
r.Item("Address") = Me.TextBox3.Text
r.Item("City") = Me.TextBox4.Text
r.Item("State") = Me.TextBox5.Text
r.Item("Zip") = Me.TextBox6.Text
r.Item("Phone") = Me.TextBox7.Text
r.Item("Fax") = Me.TextBox8.Text
r.Item("Email") = Me.TextBox9.Text
r.Item("Type") = Me.TextBox10.Text
Me.CustomerDataset11.Tables("Customer").Rows.Add(r)
Try
Me.OleDbDataAdapter1.Update(Me.CustomerDataset11.GetChanges(DataRowState.Added))
Me.OleDbDataAdapter1.Update(Me.CustomerDataset11.GetChanges(DataRowState.Modified))
Me.CustomerDataset11.AcceptChanges()
Me.OleDbDataAdapter1.Fill(CustomerDataset11.Tables("Customer"))
Catch ex As Exception
End Try
Me.OleDbConnection1.Close()
Catch ex1 As Exception
Console.WriteLine(ex1.ToString())
End Try
End Sub