Hello everyone
Im new at this thing of programming and im having trouble in saving a new record to the database, I've searched online for this problem and ive tried all the possible ways that i find in internet but i cant manage to make it work correctly
This is my save button, and i want to make it simpler, it was way easier in VB6 but for some reason i cant make it here in VB2005
Private Sub ClientesBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Save.Click
Dim da As OleDb.OleDbDataAdapter
Dim cb As New OleDb.OleDbCommandBuilder
Dim dsNewRow As DataRow
Dim strSQL As String = "Select * from clientes"
Dim strConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & strAppPath & "pizzeria.mdb ;Persist Security Info=False"
da = New OleDb.OleDbDataAdapter(strSQL, strConn)
da.Fill(PizzeriaDataSet, "clientes")
'ds = New DataSet()
Try
dsNewRow = PizzeriaDataSet.Tables("clientes").NewRow()
dsNewRow.BeginEdit()
dsNewRow("telefono") = TelefonoTextBox.Text
dsNewRow("nombres") = NombresTextBox.Text
dsNewRow("direccion") = DireccionTextBox.Text
dsNewRow("detalles") = DetallesTextBox.Text
dsNewRow.EndEdit()
PizzeriaDataSet.Tables("clientes").Rows.Add(dsNewRow)
cb = New OleDb.OleDbCommandBuilder(da)
da.InsertCommand = cb.GetInsertCommand
da.Update(PizzeriaDataSet, "clientes")
Catch oException As Exception
MessageBox.Show(oException.Message)
End Try
'Me.ClientesTableAdapter.Update(Me.PizzeriaDataSet.clientes)
TelefonoTextBox.Enabled = False
NombresTextBox.Enabled = False
DireccionTextBox.Enabled = False
DetallesTextBox.Enabled = False
sbox.Enabled = True
End Sub
This are the elements for the connection to the database that ive create in Design View
pizzeriaDataSet
pizzas /Data Binding
ClientesTableAdapter
I dont know what more to do to make that button save in the database.
Note: using access 2007 database
please help