PC Review


Reply
Thread Tools Rate Thread

DataAdapter.Update method problem.

 
 
Emil
Guest
Posts: n/a
 
      25th Dec 2006
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


 
Reply With Quote
 
 
 
 
Jacob
Guest
Posts: n/a
 
      26th Dec 2006
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.


Emil wrote:
> 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


 
Reply With Quote
 
Emil
Guest
Posts: n/a
 
      26th Dec 2006

Uzytkownik "Jacob" <(E-Mail Removed)> napisal w wiadomosci
news:(E-Mail Removed)...
> 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).


 
Reply With Quote
 
Emil
Guest
Posts: n/a
 
      26th Dec 2006

Użytkownik "Emil" <(E-Mail Removed)> napisał w wiadomości
news:emqrr0$q4r$(E-Mail Removed)...
>
> Uzytkownik "Jacob" <(E-Mail Removed)> napisal w wiadomosci
> news:(E-Mail Removed)...
>> 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).
>

I've solved the problem. I switched from Access to SQL Express and now
everything works fine

Thanks for help anyway


 
Reply With Quote
 
Cor Ligthert [MVP]
Guest
Posts: n/a
 
      26th Dec 2006
Emil,

To nie moze byc prawda

Cor

"Emil" <(E-Mail Removed)> schreef in bericht news:emqub6$s9l$(E-Mail Removed)...
>
> Użytkownik "Emil" <(E-Mail Removed)> napisał w wiadomości
> news:emqrr0$q4r$(E-Mail Removed)...
>>
>> Uzytkownik "Jacob" <(E-Mail Removed)> napisal w wiadomosci
>> news:(E-Mail Removed)...
>>> 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).
>>

> I've solved the problem. I switched from Access to SQL Express and now
> everything works fine
>
> Thanks for help anyway
>
>

 
Reply With Quote
 
Emil
Guest
Posts: n/a
 
      27th Dec 2006
Ich habe das in bericht nicht geschreiben.

Uzytkownik "Cor Ligthert [MVP]" <(E-Mail Removed)> napisal w wiadomosci news:(E-Mail Removed)...
Emil,

To nie moze byc prawda

Cor

"Emil" <(E-Mail Removed)> schreef in bericht news:emqub6$s9l$(E-Mail Removed)...
>
> Użytkownik "Emil" <(E-Mail Removed)> napisał w wiadomości
> news:emqrr0$q4r$(E-Mail Removed)...
>>
>> Uzytkownik "Jacob" <(E-Mail Removed)> napisal w wiadomosci
>> news:(E-Mail Removed)...
>>> 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).
>>

> I've solved the problem. I switched from Access to SQL Express and now
> everything works fine
>
> Thanks for help anyway
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Timeout on dataAdapter Update method larzeb Microsoft ADO .NET 10 4th Jun 2005 03:11 AM
DataAdapter and Update method Microsoft ASP .NET 0 2nd Dec 2003 04:11 AM
Using DataAdapter Update method from a component STom Microsoft ADO .NET 5 21st Oct 2003 09:06 PM
DataAdapter update method fails Lars Beyer-Olsen Microsoft ADO .NET 6 16th Sep 2003 06:38 PM
DataAdapter.Update method woes J.G.K. Microsoft ADO .NET 0 18th Aug 2003 10:36 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:30 AM.