Julio Motol Julio Motol - 11 days ago 6
C# Question

retrieve single data from a database with linq to sql

i have a table that goes like this.

CREATE TABLE [dbo].[loginInfos] (
[loginId] INT IDENTITY (1, 1) NOT NULL,
[username] VARCHAR (50) NULL,
[password] VARCHAR (50) NULL,
PRIMARY KEY CLUSTERED ([loginId] ASC)
);


now i want to get the username and compare it with a input from a textbox. it will really be a huge help.

Answer
var MyDb = new MyDb ("c:\\Data\\MyDb .mdf");

var user = =
from u in MyDb.loginInfos
where u.username== txtUsername.Text
select u;
Comments