tags:

views:

677

answers:

2

Hello, I have imported a ms access database into ms visual c# 2008, it read the fields in the database, but when updating it only updates the dataset and not the actual database,

function code

    System.Data.OleDb.OleDbDataAdapter da;

 private void button2_Click(object sender, EventArgs e)
 {
        System.Data.OleDb.OleDbCommandBuilder cb;
        cb = new System.Data.OleDb.OleDbCommandBuilder(da);

        DataRow dRow = ds1.Tables["ever"].NewRow();

        dRow[1] = textBox1.Text;
        dRow[2] = textBox1.Text;
        dRow[3] = textBox1.Text;

        ds1.Tables["ever"].Rows.Add(dRow);

        da.Update(ds1, "ever");

        MessageBox.Show("Record added");
    }

but error of

"The ConnectionString property has not been initialized."

at code :

da.Update(ds1, "ever");

thanks

A: 

is there a commit instruction in c# ms access library?

A.Rashad
learning in progress,commit instruction?.
I mean there might be a problem in the API that it requires to make a commit for your Data Manipulation Instruction (Update, Insert, Delete). Well, this is more of an Oracle property anyways, I don't think you would face that problem in MS Access since it is a single user Database anyways.
A.Rashad
A: 

The Update method uses the command you specify in the UpdateCommand property. I suspect that is part of your problem. There is probably a similar property for the connection string for each of the commands (SELECT, INSERT, UPDATE, DELETE).

PeteT