hi, when i click the add button it says successful but when i look up in the database nothings added..
its have 2 textboxes for firstname and surname
1 button for add
my table is compose of fields FirstName and Surname
how can i solve this?
here's my code... anyway thanks in advance
Code:Public Class Form1 Dim inc As Integer 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 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load dbprovider = "Provider=Microsoft.JET.OLEDB.4.0;" dbsource = "Data Source=C:\AddressBook.mdb" con.ConnectionString = dbprovider & dbsource con.Open() sql = "SELECT * FROM tblContacts" da = New OleDb.OleDbDataAdapter(sql, con) da.Fill(ds, "AddressBook") con.Close() End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim cb As New OleDb.OleDbCommandBuilder(da) Dim dsNewRow As DataRow dsNewRow = ds.Tables("AddressBook").NewRow() dsNewRow.Item("FirstName") = TextBox1.Text dsNewRow.Item("Surname") = TextBox2.Text da.Update(ds, "AddressBook") MsgBox("New Record added to the Database") End Sub End Class




Reply With Quote