Silverlight application 看來像要運用WCF連接資料庫,先試一下Linq to SQL
工作環境: Windows 7 (x86), VS2010, SQL 2008 R2
1. VS 2010 伺服器管理,連接資料庫
2. 主控台專案,加入新項目(資料 > Linq To SQL 類別) DataClass1.dbml
3. 拖取資料表(Table)進入DataClass1.dbml
4. 記得全部儲存。
5. 測試程式:
static void Main(string[] args)
{
DataClasses1DataContext db = new DataClasses1DataContext();
var ths = (
from us in db.teacher
select new { us.user, us.Email, us.education }).Take(2);
foreach (var t in ths)
{
Console.WriteLine(t.user +"," + t.Email + "," + t.education);
}
}
6.
沒有留言:
張貼留言