473,395 Members | 1,452 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 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 1584
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

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

Similar topics

2
by: Rotsey | last post by:
Hi, I had a VS2003 ASP.NET application working fine and running ok. I also have VS2005 installed and recently installed the LINQ CTP and BLINQ. In the process of getting this to work when I...
18
by: martin | last post by:
I'm just wondering... Will it be possible to use C# 3.0 and Linq to objects without having our users download the .NET Framework 2.0 client? I really would like to use the C# 3.0 features, but I...
0
by: d-42 | last post by:
You wrote a great deal and there is so much I would have liked to elaborate on but this really de-railed the whole debate. You posted that linq DOES throw an exception if its not ordered, and that...
3
by: Leo Seccia | last post by:
Hello everyone, I have a c# project with a sql server database. I have a number of lookup tables in my database which I successfully managed to import into my LINQ dataclasses. eg. Table:...
0
by: Lloyd Sheen | last post by:
In testing I am adding / removing items using linq. Steps: 1. Add new item using InsertOnSubmit and SubmitChanges with no problem. 2. Remove the item using DeleteOnSubmit and...
43
by: John | last post by:
Hi This .net is driving me crazy!! In VB6 I had a type which contained a couple of multi-dimentional arrays which i used to create and read records: Type AAA : Array1(10,10,2) as Integer
5
by: =?Utf-8?B?U2llZ2ZyaWVkIEhlaW50emU=?= | last post by:
Can someone help me convert this to the latest C# syntax using predicate/delegate? You can see my attempt in the comments. Also: how would I set a new font for q_ul? q_ul is a WPF TextBlock and I...
2
by: Neil Chambers | last post by:
All, I have a class describing various actions to take against a LINQ to SQL datasource. What are the pros/cons of instantiating the LINQ object either in the root of the class (for lack of a...
7
by: shapper | last post by:
Hello, Is it possible to multiply all Prices in a List<Productby 1.1 using Linq? Product has a property named Price. Thanks, Miguel
1
by: aboalnodom | last post by:
hello guys, i hope any one will help in this i am designing a web application, the page i am workin on its the default.aspx it contains dropdownboxes the first 4 to choose the type and the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.