Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ID returning null after insert with auto-increment primary key #241

Closed
luisvsilva opened this issue Oct 20, 2015 · 2 comments
Closed

ID returning null after insert with auto-increment primary key #241

luisvsilva opened this issue Oct 20, 2015 · 2 comments

Comments

@luisvsilva
Copy link

After insert, ID property is set to null.

Changing:
this:
cmd.CommandText = "SELECT SCOPE_IDENTITY()";

to:
cmd.CommandText = "SELECT @@IDENTITY as newID";

in Insert method, fixed it.

Also why is ID hardcoded, shouldnt we be using the PrimaryKeyField property as per stated in the documentation?

I can submit a push request if needed.

Thanks

@FransBouma
Copy link
Owner

Could you try the version in the refactoring branch? I've been refactoring Massive in the past months (when I have time), fixed some bugs and made things better (and added tests!). To use, use 2 files: the Massive.Shared and the Massive.your database

About your fix: it suggests you have a trigger on the table, is that correct?

@luisvsilva
Copy link
Author

I will try the version in the re-factoring branch and check back.

About the fix: No triggers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants