I am working on a form which uses an Access (oledb) database, I have a button to update, and other to insert a new client, when I insert a new client it successfully adds it to the database, but I have to open and close the form to update it, is there a way to make it that when I add the client, or press a button it refreshes the database without closing the form? I am using comboboxes to select clients, thats why I ask.
Thanks in advance!

hi there?
yes there is a way to refresh the database without closing and opening it again. what you do is very simple just use the code thats loading the database but this time write it in the new client form and use the CALL method. after the message that shows a new client has been added successfully below it add these two words
call loadclients.

NB. loadclients represents the code that you've coded to load clients.

hope this will help.

cheers

The thing is that I didn't make the connections by hand with code, the visual thing made them for me basically.

Just load the database again after you insert, update or delete records

I use this code

myCommand = New OleDbDataAdapter _
      ("select * from TableName", MyConnection)
        DtSet = New DataSet
        myCommand.Fill(DtSet)
        DataGridView1.DataSource = DtSet.Tables(0)

If you made your connection using the wizard thingy you're talking about. I hope this helps you

Edited 3 Years Ago by jared.geli: Update

I adapted it so it doesnt give any errors and fits my code, but it isnt working, any help? (I mean, it wont update the combobox content).

            con = New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Resumen Guia\Base.mdb")
            str = "select * from Tabla"
            cmd = New OleDb.OleDbCommand(str, con)
            dataadapter1.SelectCommand = cmd
            dataadapter1.Fill(BaseDataSet)
            ComboBox1.DataSource = BaseDataSet.Tables(0)
        Dim con = New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Resumen Guia\Base.mdb")
        Dim dataadapter1 As New System.Data.OleDb.OleDbDataAdapter()
        dataadapter1 = New System.Data.OleDb.OleDbDataAdapter("select * from Tabla ", con)
        Dim DtSet As System.Data.DataSet
        DtSet = New System.Data.DataSet
        dataadapter1.Fill(DtSet)
        ComboBox1.DataSource = Nothing
        ComboBox1.DataSource = DtSet.Tables(0)
        con.Close()

Edited 3 Years Ago by oussama_1

This question has already been answered. Start a new discussion instead.