Adding a parent for existing child row. (typed datasets)

  • Thread starter news.microsoft.com
  • Start date
N

news.microsoft.com

I have two database tables USER N - 1 PICTURE. (one picture can be
chosen by many users). A lot of users have not yet selected a picture,
so the foreign key pictureID in the USER-table is NULL.

I use typed datasets and use the VS.Net wizards to create dataadapters
and tables withing the datasets. I set the relationships myself and use
seed -1 and increment -1 and autoincrement true.

When I load my data into the datasets, I will have lots of children
(users) without parents (pictures). For one user I upload a picture, add
a new PictureRow in the myDataSet.Picture array and call
myDataAdapter.update(myDataSet, "PICTURE"). I then get this annoying
exception:

Prepared statement '(@username nvarchar(20),@password
nvarchar(20),@lastlogin date' expects parameter @username, which was not
supplied.

I dont understand this... Can anyone point me in the right direction so
i can help my orphanes get parents?

(I'm using SQL Server 2k, identity keys and db referential integrity)
 
S

Sahil Malik

Run a trace, see the query being generated by ado.net for you - chances are
it is not what you expect it to be. Specify your own query explicitly that
does exactly what you want it to do.

Also, the problem could be in other areas too as per the description
mentioned below; but the above is a high probability hit !! :)

- Sahil Malik
http://dotnetjunkies.com/weblog/sahilmalik
 
M

Marius

Sahil said:
Run a trace, see the query being generated by ado.net for you - chances are
it is not what you expect it to be. Specify your own query explicitly that
does exactly what you want it to do.

Also, the problem could be in other areas too as per the description
mentioned below; but the above is a high probability hit !! :)

Sahil, thanks for your tips. I am a little emberrased now. The error was
mine. I had swithed the names of my datahandler class methods. My
..SaveUser(myDataSet) had code for updating the picture table and vice
versa. Changed them and noe it all works fine.

*Blushing*
 

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