.NETѧϰÊÖ¼ÇÖ®£ºlinq to SQL(¶þ)
ÔÚVisual Studio 2008 ÖÐʹÓÃO/RÉè¼ÆÆ÷£º
µãÌí¼ÓÏîÄ¿£¬Ñ¡Ôñ´´½¨Linq to SQLÏîÄ¿£¬Ê¹Ó÷þÎñÆ÷×ÊÔ´¹ÜÀíÆ÷Á¬½ÓNorthwindÊý¾Ý¿â£¬½«CustomersºÍOrdersÁ½¸ö±íÍϵ½Éè¼Æ½çÃæÉÏ£¬ÏµÍ³»á×Ô¶¯´´½¨app.configºÍNorthwid.designer.cs,Ç°ÕßÊÇÅäÖÃÁ¬½ÓÊý¾Ý¿âµÄÁ¬½Ó×Ö´®£»ºóÕß»áÉú³ÉÒ»¸ö¼Ì³Ð×ÔDataContextµÄÀࣺNorthwindDataContext¡£
ʹÓÃlinqµ÷³öÊý¾Ý£º
static void Main(string[] args)
{
NorthwindDataContext dc= new NorthwindDataContext();
dc.Log=Console.Out;
var query=from c in dc.Customers
join o in dc.Orders on c.CustomerID equals o.CustomerID
orderby c.CustomerID
select new {
c.CustomeriD,c.CompanyName,c.Country,o.OrderID,o.OrderDate};
foreach(var item in query)
{
Console.WriteLine(item.CustomerID+"|"+item.CompanyName
+"|"+item.Country+"|"+item.OrderID
+"|"+item.OrderDate);
}
}
ʹÓô洢¹ý³Ì£º
½«´æ´¢¹ý³ÌÍϵ½O/RÉè¼ÆÆ÷µÄÓÒ²àÇøÓò¡£
static void Main(string[] args)
{
NorthwindDataContext dc= new NorthwindDataContext();
ISingleResult<Ten_Most_Expensive_ProductsResult> result=
dc.Ten_Most_Expensive_Products();
foreach(Ten_Most_Expensive_ProductsResult item in result)
{
Console.WriteLine(item.TenMostExpensiveProducts+"|"+
item.UnitPrice);
}
}
Ïà¹ØÎĵµ£º
Ò»¡¢Ê¹ÓÃSqlConnection¶ÔÏóÁ¬½ÓSQL ServerÊý¾Ý¿â
1¡¢µÇ¼Êý¾Ý¿âµÄ·½Ê½ÎªSQL ServerÑé֤ģʽ
server=·þÎñÆ÷Ãû;database=Êý¾Ý¿âÃû³Æ;uid=Óû§;pwd=ÃÜÂë
2¡¢µÇ¼Êý¾Ý¿âµÄ·½Ê½ÎªWindowsÑé֤ģʽ
server=·þÎñÆ÷Ãû;database=Êý¾Ý¿âÃû³Æ;Integrated Security=SSPI
ÆäÖУ¬Integrated Security¼´Trusted_Connection,È¡Ö ......
ÔÚ2005ÖÐÓÐͬÒå´ÊÓ븴ÖƵĸÅÄî
ͬÒå´ÊµÄÖ÷Òª×÷ÓÃÊÇ£º
Ò»£ºË޶̶ÔÏóµÄÃû³Æ£¬¼õÉÙ¹¤×÷ÈËÔ±ÊéдµÄʱ¼ä£¬Ìá¸ßЧÂÊ¡£ÎÒÃÇÖªµÀ·ÃÎÊÊý¾Ý¿âÒ»¸ö¶ÔÏóµÄͨ³£×îÈ«µÄ¶ÔÏóÃû³ÆÊÇ£º·þÎñÆ÷Ãû³Æ¡£Êý¾Ý¿âÃû³Æ¡£¼Ü¹¹Ãû³Æ¡£¶ÔÏóÃû³Æ
¶þ£ºÍ¬²½Êý¾Ý¡£ ......
ÄãÊÇ·ñÔÚǧ·½°Ù¼ÆÓÅ»¯SQL Server Êý¾Ý¿âµÄÐÔÄÜ?Èç¹ûÄãµÄÊý¾Ý¿âÖк¬ÓдóÁ¿µÄ±í¸ñ£¬°ÑÕâЩ±í¸ñ·ÖÇø·ÅÈë¶ÀÁ¢µÄÎļþ×é¿ÉÄÜ»áÈÃÄãÊÜÒæ·Ëdz¡£SQL Server 2005ÒýÈëµÄ±í·ÖÇø¼¼Êõ£¬ÈÃÓû§Äܹ»°ÑÊý¾Ý·ÖÉ¢´æ·Åµ½²»Í¬µÄÎïÀí´ÅÅÌÖУ¬Ìá¸ßÕâЩ´ÅÅ̵IJ¢Ðд¦ÀíÐÔÄÜÒÔÓÅ»¯²éѯÐÔÄÜ¡£
¡¡¡¡SQL ServerÊý¾Ý¿â±í·ÖÇø²Ù×÷¹ý³ÌÓÉÈý¸ö²½Öè×é³É£º
¡ ......
¿ÉÒÔ¶¨ÒåÒ»¸öÎÞÂÛºÎʱÓÃINSERTÓï¾äÏò±íÖвåÈëÊý¾Ýʱ¶¼»áÖ´ÐеĴ¥·¢Æ÷¡£
¡¡¡¡µ±´¥·¢INSERT´¥·¢Æ÷ʱ£¬ÐµÄÊý¾ÝÐоͻᱻ²åÈëµ½´¥·¢Æ÷±íºÍinserted±íÖС£inserted±íÊÇÒ»¸öÂß¼±í£¬Ëü°üº¬ÁËÒѾ²åÈëµÄÊý¾ÝÐеÄÒ»¸ö¸±±¾¡£inserted±í°üº¬ÁËINSERTÓï¾äÖÐÒѼǼµÄ²åÈ붯×÷¡£inserted±í»¹ÔÊÐíÒýÓÃÓɳõʼ»¯INSERTÓï¾ä¶ø²úÉúµÄÈÕÖ¾Êý¾Ý ......
ÔÚ°²×°SQL Server 2005¿ª·¢°æʱ³öÏÖÎÊÌâ¡£°²×°»·¾³Îªwindows xp sp3£¬°²×°Óû§Ê¹Ó󬼶¹ÜÀíÔ±£¨Administrator£©¡£³öÏֵĴíÎóÊÇ
ÔÚ°²×°“Integration Services”²½Öèʱ³öÏÖ°²×°´íÎó£¬Ìáʾ“´íÎó: -2146233087”¡£
´íÎó¼Ç¼
±êÌâ:
Microsoft SQL Server 2005 °²×°³ÌÐò
ÎÞ·¨ÔÚ COM+ Ŀ¼Öа²×°ºÍÅäÖ ......