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. :)

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?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.