DataAdapter.Update method problem.

E

Emil

I've created a very simple data base in Microsoft Access 2003. It consists
of only one table called "Students" and it contains 2 information about each
student: id-student and name.

When I try to manipulate data in database I get an error, here's a sample:

OleDbConnection connection;
connection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=c:\\ecdl.mdb");


OleDbDataAdapter dataAdapter = new OleDbDataAdapter ("SELECT * FROM
Students",connection);

OleDbCommandBuilder commandBuilder = new OleDbCommandBuilder(dataAdapter);

DataSet dataSet = new DataSet();

dataAdapter.Fill(dataSet, "Students");



DataRow dataRow = dataSet.Tables["Students"].Rows[4];

dataRow["Name"] = "Peter";


dataAdapter.Update(dataSet, "Students"); //here I get an error



connection.Close();

Console.ReadLine();

And the error is: " Any value given for one or many parameters required"
Please help
Thanks in advance
Emil
 
J

Jacob

I'm guessing the student-id in your database table is the primary key
and that it has an auto-increment value, correct?

This does not automatically get copied into your datatable, so you need
to set AutoIncrement to true on the column and possible set the
relevant seed also.
 
E

Emil

Uzytkownik "Jacob said:
I'm guessing the student-id in your database table is the primary key
and that it has an auto-increment value, correct?

This does not automatically get copied into your datatable, so you need
to set AutoIncrement to true on the column and possible set the
relevant seed also.

id-student is the primary key but it hasn't an auto-increment value (it must
be typed by hand).
 
E

Emil

U¿ytkownik "Emil said:
id-student is the primary key but it hasn't an auto-increment value (it
must be typed by hand).
I've solved the problem. I switched from Access to SQL Express and now
everything works fine ;)

Thanks for help anyway :)
 
C

Cor Ligthert [MVP]

Emil,

To nie moze byc prawda

Cor

Emil said:
I've solved the problem. I switched from Access to SQL Express and now
everything works fine ;)

Thanks for help anyway :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top