Hello everyone this will be my first post.
I am happy that there is a forum like this with very supportive people.:)

So on topic..
I am a student creating an Inventory System software for my school using VB on VS 2008.
I am having trouble saving items from a DataGridView to Access 2007.

The codes I browsed here are quite different from what instructors teach us at our school.

These are some of the codes we are using to save items from textboxes to Access 2007 database with a table named studenttable and database named student for your added information.

Dim StudentAdapter as New OledbDataAdapter
Dim StudentBuilder as New OleDBCommandBuilder
Dim StudentDS as New DataSet
Dim con as New OleDbConnection

       con.ConnectionString = "Provider = Microsoft.Ace.Oledb.12.0; Data Source = student.accdb"

StudentAdapter = New OleDbDataAdapter("Select * from studenttable", con)
StudentBuilder = New OleDbCommandBuilder(StudentAdapter)
StudentAdapter .Fill(StudentDS , "StudentInfo")

Dim newrow As DataRow = StudentDS.Tables("StudentInfo").NewRow()
                newrow("StudentID") = textbox1.Text
                newrow("Name") = textbox2.Text
                StudentDS .Tables("StudentInfo").Rows.Add(newrow)
                StudentAdapter .Update(StudentDS , "StudentInfo")

See? Totally different from what i am seeing here.. >_<.
Hoping for replies. Thank you. :)

5 Years
Discussion Span
Last Post by Alexpap

Hi there,
welcome to our community , which i think that you will find very helpfull.

Now on topic,

instead of :

StudentAdapter .Update(StudentDS , "StudentInfo")

Try this:

StudentAdapter .Fill(StudentDS)

Here's another piece of code, that i was using to add a row into my DB:

OleDbConnection Con = new OleDbConnection(ConnectionString);
		DataSet ds = new DataSet();
		OledbDataAdapter da = new OledbDataAdapter("INSERT INTO StudentInfo(StudentId, Name) VALUES('"+textbox1.Text+"','"+textbox2.Text+"')",Con);
catch(Exception ex)
    'Write exception handling code here!

Hope i helped,
Alex. :)


Thank you. This really helped.
But I think the "StudentAdapter.Fill(StudentDS)" doesn't fill up the access 2007 database.


Thank you. This really helped.
But I think the "StudentAdapter.Fill(StudentDS)" doesn't fill up the access 2007 database.

Did you try it? Were there any exceptions thrown?

This article has been dead for over six months. Start a new discussion instead.
Take the time to help us to help you. Please be thoughtful and detailed and be sure to adhere to our posting rules.