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

Êý¾Ý¿â×é¼þ Hxj.Data£¨Æß£© (sqlƪ)

ÉÏÒ»½Ú½²ÊöµÄÊÇɾ³ý²Ù×÷£¬±¾½Ú½«½²ÊöÈçºÎÖ±½ÓÖ´ÐÐsqlÓï¾ä¡£ Ö±½ÓÖ´ÐÐsqlÓï¾äÊÇʹÓÃfromSql·½·¨¡£ DbSession.Default.fromSql("select * from products").ToDataTable();
 
ÕâÑù¿´ÆðÀ´Ç×ÇжàÁ˰ɣ¬Ö±½Ósql¾Í¿ÉÒÔÖ´ÐС£
 
µ±È»Ò²¿ÉÌí¼Ó²ÎÊýµÄ°¡¡£
DbSession.Default.fromSql("select * from products where productid=pid").AddInParameter("pid", DbType.Int32, 1).ToDataTable();

ÕâÑùµÄ²éѯÌõ¼þÊÇproductid=1·µ»ØÒ»Ìõ¼Ç¼¡£
ÕâÀïsqlÓï¾äÖÐpidҪȷ±£Î¨Ò»£¬²»È»¶¼»á±»Ìæ»»³É²ÎÊýµÄ¡£
±ÈÈ磺select * from products where productid=productid ÕâÑùÔÚsqlserverÏÂ¾Í»á±»Ìæ»»³Éselect * from products where @productid=@productid
ÕâÀïÖ»ÊÇ×öÁ˼òµ¥µÄÌæ»»£¬ËùÒÔÈ·±£ÉêÃ÷µÄ²ÎÊýΨһÐÔ¡£
 
µ±¶à¸ö²ÎÊýʱ¿ÉÈçÏÂд·¨£º
DbParameter[] parameters = new DbParameter[2];
parameters[0] = DbSession.Default.Db.DbProviderFactory.CreateParameter();
parameters[0].DbType = DbType.Int32;
parameters[0].ParameterName = "pid";
parameters[0].Value = 1;
parameters[1] = DbSession.Default.Db.DbProviderFactory.CreateParameter();
parameters[1].DbType = DbType.Int32;
parameters[1].ParameterName = "cid";
parameters[1].Value = 2;
DbSession.Default.fromSql("select * from products where productid=pid or categoryid=cid")
.AddParameter(parameters)
.ToDataTable();

 
ÕâÑùÐ´ËÆºõÌ«Âé·³ÁË£¬¸ü¼ò½àµÄд·¨ÈçÏ£º
DbSession.Default.fromSql("select * from products where productid=pid or categoryid=cid")
.AddInParameter("pid", DbType.Int32, 1)
.AddInParameter("cid", DbType.Int32, 2)
.ToDataTable();

 
ÕâÑù¾ÍÇåˬ¶àÁË¡£
 
·µ»ØÀàÐÍ»¹¿ÉÒÔÈçÏ£º
 
IDataReader ToDataReader()
·µ»ØDataReader
 
DataSet ToDataSet()
·µ»ØDataSet
 
int ExecuteNonQuery()
·µ»ØÊÜÓ°ÏìµÄÌõÊý
 
object ToScalar()
·µ»Øµ¥¸öÖµ
 
TResult ToScalar<TResult>()
·µ»ØÖ´ÐÐÀàÐ͵ÄÖµ
 
Ò²¿É·µ»ØÊµÌå¡£
TEntity ToFirst<TEntity>()
·µ»ØµÚÒ»Ìõ


Ïà¹ØÎĵµ£º

ÓÃSQLÓï¾ä´´½¨±í&ÓÃSQLÓï¾ä´´½¨Êý¾Ý¿â

Êý¾Ý¿âÖеÄËùÓÐÊý¾Ý´æ´¢ÔÚ±íÖС£Êý¾Ý±í°üÀ¨ÐкÍÁС£Áоö¶¨Á˱íÖÐÊý¾ÝµÄÀàÐÍ¡£Ðаüº¬ÁËʵ¼ÊµÄÊý¾Ý¡£ 
ÀýÈ磬Êý¾Ý¿âpubsÖеıíauthorsÓоŸö×ֶΡ£ÆäÖеÄÒ»¸ö×Ö¶ÎÃûΪΪau_lname£¬Õâ¸ö×ֶα»ÓÃÀ´´æ´¢×÷ÕßµÄÃû×ÖÐÅÏ¢¡£Ã¿´ÎÏòÕâ¸ö±íÖÐÌí¼ÓÐÂ×÷Õßʱ£¬×÷ÕßÃû×־ͱ»Ìí¼Óµ½Õâ¸ö×ֶΣ¬²úÉúÒ»ÌõмǼ¡£ 
ͨ¹ý¶¨Òå×ֶ䪎 ......

sql server°²×°°æ±¾²é¿´


SELECT SERVERPROPERTY('productversion'), SERVERPROPERTY ('productlevel'), SERVERPROPERTY ('edition')
productversion£º²úÆ·°æ±¾£¨ÀýÈ磬10.0.1600.22£©
productlevel£º²úÆ·¼¶±ð£¨ÀýÈ磬RTM£©
edition£º°æ±¾£¨ÀýÈ磬 Enterprise£¨ÆóÒµ°æ£©¡¢Developer Edition£¨¿ª·¢°æ£©£©
SELECT @@VERSION
΢Èí¾ßÌå˵Ã÷£º
......

mysqlºÍsql server

ÔÚÐÔÄÜÉÏ£¬mysqlÊÇÏ൱³öÉ«µÄ£¬×ÀÃæ¸ñʽmyisamÊý¾Ý¿âÓë´ÅÅ̷dz£µØ¼æÈݶø²»Õ¼Óùý¶àµÄcpuºÍÄڴ棬mysqlÄÚ²¿ºÜ¶àʱºò¶¼Ê¹ÓÃ64λÕûÊý´¦Àí¡£yahoo¾ÍʹÓÃmysqlºǫ́Êý¾Ý¿â¡£
µ«mysqlȱÉÙһЩ¸½¼Ó¹¦ÄÜ£¬Ã»ÓÐSqlServerÈ«Ãæ¡£
sqlserverÎȶ¨ÐÍÇ¿£¬µ«±ØÐëÔö¼Ó¶îÍ⸴ÔÓ²Ù×÷£¬´ÅÅÌ´æ´¢£¬ÄÚ´æËðºÄµÈ£¬¶ÔÓ²¼þÈí¼þÒªÇ󶼺ܸߡ£
ÕâÁ½¸öÊý ......

SQL Server·ÖÒ³3ÖÖ·½°¸

 SQL Server·ÖÒ³3ÖÖ·½°¸±ÈÆ´
´Ë×ªÔØÔ´×ÔÀîºé¸ùµÄblog.×÷ÕßÊÇ΢ÈíµÄMVP!Ï£Íû´ó¼Ò²Î¿¼ÒÔÏÂ3ÖÖ·½°¸,°´Êµ¼ÊÇé¿öÑ¡Ôñ!
½¨Á¢±í£º
CREATE TABLE [TestTable] (
 [ID] [int] IDENTITY (1, 1) NOT NULL ,
 [FirstName] [nvarchar] (100) COLLATE Chinese_PRC_CI_AS NULL ,
 [LastName] [nvarchar] (100) ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ