Julio Motol Julio Motol - 10 months ago 49
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,

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

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

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