This is a bit frustrating! I have a search section in which you can scroll through the rows using buttons and the textboxes updates to the row details but when i add new data into the database an go back to my search menu the newly added row is not showing up? How do i reset the binding source to accomplish this, or at least have the 2 parts work from the same data?
My code: Call Write2tableAddClient() `here i am hoping to add this refresh binding code
My current binding in which is triggered on form load:
Private Sub click()
sql = "Select * from tbl"
Using dbcon As New OleDbConnection(ACEConnStr)
Using cmd As New OleDbCommand(sql, dbcon)
dbcon.Open()
dtSample = New DataTable
dtSample.Load(cmd.ExecuteReader)
End Using
End Using
' initialize BS from DT
bsSample = New BindingSource(dtSample, Nothing)
TxtCI.DataBindings.Add("Text", bsSample, "ID")
End Sub
AddCustomer:
Private Sub AClient()
If con.State = ConnectionState.Closed Then con.Open()
cmd = New OleDbCommand
cmd.Connection = con
cmd.CommandText = "INSERT INTO tblcustomer(Title)VALUES(?);"
cmd.Parameters.Add("?", OleDbType.VarChar).Value = TxtName.Text
cmd.ExecuteNonQuery()
con.Close()
End Sub
Headings:
Dim con As OleDbConnection = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=.\Database.accdb")
Dim cmd As OleDbCommand
Dim sql As String
Dim ds As New DataSet
Dim da As New OleDbDataAdapter
Dim RecCnt As Integer
Dim inc As Integer
Private ACEConnStr As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=.\Database.accdb"
Private bsSample As BindingSource
Private dtSample As DataTable