Inserting data using Linq

Posted by Ani on Stack Overflow See other posts from Stack Overflow or by Ani
Published on 2010-04-26T17:27:20Z Indexed on 2010/04/26 17:33 UTC
Read the original article Hit count: 239

Filed under:
|

I have a linq query to insert data in table. but its not working. I saw some example on internet tried to do like that but doesn't seems to work.

Tablename: login has 3 columns userid, username and password. I set userid as autoincrementing in database. So I have to insert only username and password everytime.Here's my code.

linq_testDataContext db = new linq_testDataContext();
login insert = new login();
            insert.username = userNameString;
            insert.Password = pwdString;
            db.logins.Attach(insert);// tried to use Add but my intellisence is not showing me Add.I saw attach but dosent seems to work.
            db.SubmitChanges();

© Stack Overflow or respective owner

Related posts about insert

Related posts about LINQ