472,133 Members | 1,469 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,133 software developers and data experts.

Problem in using LINQ to SQL

I am doing my project using LINQ to SQL technology for the database part. I wrote the coding for inserting a new record into the table. The coding was ok. Its working 100%. But after inserting the data into the table when I run next time in the Visual studio 2008 I cound'nt get the previously inserted data. Which means only in that instance I register, I was able to get the inserted data.

Also there is another problem. I have the Users.mdf file. When I open it to see the inserted records its not there. If you want to see the coding, here is it.

try
{


UsersDBDataContext context = new UsersDBDataContext();
var usersData =
from Usr in context.Users
where Usr.UserName == txtSignUpUserName.Text
select new { Usr.UserName };

if (usersData.Count() == 0)
{



User newUser = new User
{
RealName = txtRName.Text,
UserName = txtSignUpUserName.Text,
Password = pwbSignUpPassword.Password,
Country = ComCountry.Text,



};
context.Users.InsertOnSubmit(newUser);


context.SubmitChanges();


}
else
MessageBox.Show("User name already exists");

}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}


Can any body help me with this???????
Jul 19 '08 #1
2 1525
ck9663
2,878 Expert 2GB
Where's the part that insert the record?

-- CK
Jul 19 '08 #2
Where's the part that insert the record?

-- CK
Hey this is LINQ - Language INtergrated Query

User newUser = new User // Create a new object
{
RealName = txtRName.Text,
UserName = txtSignUpUserName.Text,
Password = pwbSignUpPassword.Password,
Country = ComCountry.Text,



};
context.Users.InsertOnSubmit(newUser); // Submit the new object 2 da db


context.SubmitChanges();
Jul 20 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

18 posts views Thread by martin | last post: by
3 posts views Thread by Leo Seccia | last post: by
reply views Thread by Lloyd Sheen | last post: by
43 posts views Thread by John | last post: by
5 posts views Thread by =?Utf-8?B?U2llZ2ZyaWVkIEhlaW50emU=?= | last post: by
2 posts views Thread by Neil Chambers | last post: by
7 posts views Thread by shapper | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.