Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

.NETѧϰÊÖ¼ÇÖ®£ºlinq to SQL(Ò»)


Ò»¸ö¼òµ¥µÄÀý×Ó£º
ÏȽ¨Ò»¸öC#Àࣺ
ÒýÓÃSystem.Data.Linq.dll³ÌÐò¼¯£¬
using System.Data.Linq.MappingºÍ
using System.Data.Linq Á½¸ö¿Õ¼ä¡£
[Table]
public class Inventory
{
   [Column]
   public string Make;
   [Column]
   public string Color;
   [Column]
   public string PetName;
  
   //Ö¸Ã÷Ö÷¼ü¡£
   [Column(IsPrimaryKey = true)]
   public int CarID;
  
   public override string ToString()
   {
       return string.Format(
        "±àºÅ={0};ÖÆÔìÉÌ={1};ÑÕÉ«={2};°®³Æ={3}",
         CarID,Make.Trim(),Color.Trim(),PetName.Trim());
   }
}
ÓëSQL(express°æ)Êý¾Ý¿â½»»¥:
class Program
{
   const string cnStr=
       @"Data Source=(local)\SQLEXPRESS;Initial Catalog=Autolot;"+
            "Integrated Security=True";
   static void Main(string[] args)
   {
       Console.WriteLine("*****LINQ to SQL ¼òµ¥Ó¦ÓÃ*****");
       //´´½¨Ò»¸öDataContext¶ÔÏó¡£
       DataContext db= new DataContext(cnStr);
       //´´½¨Ò»¸öTable<>·ºÐÍʵÀý¡£
       Table<Inventory> invTable = db.GetTable<Inventory>();
       //ÓÃÒ»¸öLINQ²éѯÏÔʾ½á¹û¡£
       foreach(var car in from c in invTable select c)
           Console.WriteLine(car.ToString());
   }
   Console.ReadLine();
}
¶ÔDataContextÀà½øÐÐÀ©Õ¹£º
class MyAutoLotDatabase:DataContext
{
   public Table<Inventory> Inventory;
   public MyAut


Ïà¹ØÎĵµ£º

±È½ÏÁ½¸öSQLµÄÖ´ÐÐʱ¼ä

±È½ÏÁ½¸öSQLµÄÖ´ÐÐʱ¼ä
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[PROC_SQL_COMP]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[PROC_SQL_COMP]
GO
/*--²âÊÔÁ½×éSQLµÄƽ¾ùʱ¼ä
 
 ÀûÓÃosql.exeÀ´²âÊÔÁ½×é SQL Óï¾äµÄÖ´ÐÐʱ¼ä
 ²âÊԵĴ洢¹ý³ ......

SQL½»²æ±í²éѯ ÈçºÎʵÏÖ

Çë½Ì´ó¼ÒÒ»¸öÓйØSQL½»×¤±¨±í²éѯÎÊÌ⣬»¶Ó­¸÷λָ½Ì£¡
ÎÒÏë°Ñͼ1µÄʹÓÃÐÅÏ¢£¬Ê¹ÓÃSQLÓï¾ä£¬ÊµÏÖÈçͼ2µÄ½á¹û¡£
±íÃû
ÐòºÅ
×Ö¶ÎÃû
a
1
c
a
2
d
a
3
e
a
4
f
a
5
g
b
1
h
b
2
i
b
3
j
b
4
k
b
5
l
c
1
m
c
2
n
c
3
o
c
4
p
c
5
q
ͼ1
 
±íÃû
ÐòºÅ
1
2
3
4
5 ......

ÀûÓÃSQLÒƶ¯Ó²ÅÌÎļþ

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[p_movefile]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[p_movefile]
GO
/*--Òƶ¯·þÎñÆ÷ÉϵÄÎļþ
 ²»½èÖú xp_cmdshell ,ÒòΪÕâ¸öÔÚ´ó¶àÊýʱºò¶¼±»½ûÓÃÁË
--×Þ½¨ 2004.08(ÒýÓÃÇë±£Áô´ËÐÅÏ¢)--*/
/*--µ÷ÓÃʾÀý ......

½â¾öSQL ServerÀïsp_helptextÊä³ö¸ñʽ´íÐÐÎÊÌâ

use Master 
go 
if object_id('SP_SQL') is not null 
  drop proc SP_SQL 
go 
create proc [dbo].[SP_SQL](@ObjectName sysname) 
as 
set nocount on ; 
declare @Print varchar(max) 
if exists(select 1 from syscomments  where ID=objec ......

SQL Server±í·ÖÇø²Ù×÷Ïê½â

ÄãÊÇ·ñÔÚǧ·½°Ù¼ÆÓÅ»¯SQL Server Êý¾Ý¿âµÄÐÔÄÜ?Èç¹ûÄãµÄÊý¾Ý¿âÖк¬ÓдóÁ¿µÄ±í¸ñ£¬°ÑÕâЩ±í¸ñ·ÖÇø·ÅÈë¶ÀÁ¢µÄÎļþ×é¿ÉÄÜ»áÈÃÄãÊÜÒæ·Ëdz¡£SQL Server 2005ÒýÈëµÄ±í·ÖÇø¼¼Êõ£¬ÈÃÓû§Äܹ»°ÑÊý¾Ý·ÖÉ¢´æ·Åµ½²»Í¬µÄÎïÀí´ÅÅÌÖУ¬Ìá¸ßÕâЩ´ÅÅ̵IJ¢Ðд¦ÀíÐÔÄÜÒÔÓÅ»¯²éѯÐÔÄÜ¡£
¡¡¡¡SQL ServerÊý¾Ý¿â±í·ÖÇø²Ù×÷¹ý³ÌÓÉÈý¸ö²½Öè×é³É£º
¡ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ