By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,204 Members | 1,469 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,204 IT Pros & Developers. It's quick & easy.

Getting autonumber field (MSDE2000 )

P: n/a

2 questions

This code is in the mda.Updated event ; why does the ExecuteScalar returns a
decimal while in the table definition the keyfield is declared as int ?

SqlCommand Cmd = new SqlCommand("SELECT @@IDENTITY",

Decimal lastid =(decimal)Cmd.ExecuteScalar();

After the record insertion the newrecord["autonumberkeyfield"] is not
updated to the last @@IDENITY ,

when i write this after calling mda.Update()

newrecord["autonumberkeyfield"] =Convert.ToInt32(lastid); yields a readonly

How can i get my newrecord containing the correct keyfield ?


May 17 '06 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.