开发者

Tutorial on displaying datasets from a SQL Server database using C#

I am using Visual Studio 2008 and I am a beginner.

I am connecting to a SQL Server 2008 database.

I would like to display data from a tab开发者_Python百科le.

How do I do this? Can someone please show me an easy tutorial?


An easy way to get started is with LINQ To SQL.

Use this tutorial to set up LINQ To SQL for your database. You only need to follow the Create LINQ to SQL Classes section.

Then, you access the data like this:

using (var db = new MyDbDataContext())
{
    var myRecord= db.MyTable.FirstOrDefault();
    Console.WriteLine(myRecord.MyColumn.ToString());
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜