Hi, this is my first post, and I'm in need of some help making an application that saves the data from a textbox to an access database.
This is my code, it gives no errors, but when I use it, ie, I input the text in the textbox and click update, it won't work, the value won't be added to the database, any help is appreciated.
Imports System.Data.OleDb
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.TablaTableAdapter.Fill(Me.BaseDataSet.Tabla)
Dim objcmd As New Data.OleDb.OleDbCommand
Dim con As OleDb.OleDbConnection = New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Resumen Guia\Base.mdb")
Button1.BackColor = System.Drawing.Color.CornflowerBlue
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim con As New OleDb.OleDbConnection
Dim cmd As OleDb.OleDbCommand
Dim icount As Integer
Dim str As String
Try
con = New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Resumen Guia\Base.mdb")
'con.Open()
str = "insert into Tabla values('" & TextBox1.Text & "')"
cmd = New OleDb.OleDbCommand(str, con)
icount = cmd.ExecuteNonQuery
MessageBox.Show(icount)
Catch
End Try
'con.Close()
End Sub
Private Sub TablaBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TablaBindingNavigatorSaveItem.Click
Me.Validate()
Me.TablaBindingSource.EndEdit()
Me.TableAdapterManager.UpdateAll(Me.BaseDataSet)
End Sub
End Class
I know the con.Open and .Close are commented, but don't worry, because even uncommented they won't work.