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

·À·¶sql×¢Èë¹¥»÷£¨Ï£© ²ÎÊý»¯sql

ÉÏһƪдµÄsql×¢ÈëµÄ»ù±¾Ô­Àí£¬±¾À´Òª½Ó×ÅдÕâƪµÄ£¬µ«ÊÇÓÉÓÚʱ¼äµÄÔ­ÒòһֱûÓÐд³É£¬½ñÌìÊÇÎåÒ»¼ÙÆÚ£¬×ÜËãÊÇÄܳé¿ÕддÁË¡£
×÷Ϊһ¸ö³ÌÐòÔ±£¬·À·¶sql×¢ÈëµÄµÚÒ»ÏßÊÇÓÉÎÒÃÇÀ´ÊØ»¤µÄ£¬Ö»ÒªÎÒÃÇÔÚ³ÌÐòÖÐÁôÉÙÐíµÄ©¶´£¬¾Í»á¸ø³ÌÐòÔöÇ¿°²È«ÌØÐÔ¡£ËùÒÔÎÒÃÇÒª×öµÄÊÇҪд°²È«µÄ³ÌÐò£¬·ÀÖ¹sql×¢ÈëÔÚ³ÌÐòÌåÏÖÔÚ²»ÒªÆ´½Ósql×Ö·û´®£¬Ò»¶¨Òª²ÎÊý»¯sql»òÕßд´æ´¢¹ý³Ì£¬ÕâÀï¾Í˵˵¼òµ¥µÄ²ÎÊý»¯sql°É¡£
Àý×ÓÖÐÓÃc#ºÍoracleʵÏÖ£¬javaÖлòÕßÆäËûÊý¾Ý¿âÖеÄʵÏÖÒ²ÊÇÀàËƵġ£
using System.Data.OracleClient;//ÒýÈëoracle²Ù×÷°ü
 
//¶¨ÒåDMLÓï¾ä
string strSQL = @"select user.name from user where user.name = :userName";
//ÉϾäÖеģºuserName¾ÍÊÇsqlÓï¾äÖвÎÊýµÄռλ·û£¬Ò²¾ÍÊÇ˵ÔÚÊý¾Ý¿â·þÎñÆ÷ÖÐÖ´ÐÐÕâÌõsqlÓï¾äµÄʱºòÕâ¸öռλ·ûÒª±»ÆäËû¶«Î÷Ìæ»»µô£¬µ½µ×ÓÃʲô¶«Î÷Ìæ»»ÄØ£¬½Ó×ÅÍùÏ¿´
OracleParameter[] param = {
new OracleParameter(":userName",txtName);
}//ÕâÀﶨÒåÒ»¸ö²ÎÊýµÄÊý×飬ÀïÃæ¿ÉÒÔдÈë¶à¸ösql²ÎÊý£¬ÔÛÃǵÄÕâÀïÖ»ÓÐÒ»¸ö£¬ËùÒÔ¾ÍдÈëÒ»¸ö²ÎÊý£¬ÕâÀイռλ·ûºÍËûµÄÌæ»»Ò²¾ÍÊDzÎÊýÖµ¶ÔÓ¦ÆðÀ´ÁË£¬txtName¾ÍÊÇռλ·ûµÄÌæ»»Öµ£¬ËûÊÇÓû§½çÃæÖÐÓû§ÊäÈëµÄÖµ£¬¾ÍÊÇËû¿ÉÄܺ¬ÓÐ×¢Èë¹¥»÷µÄ×Ö·û£¬ÕâÏÂÊý¾Ý¿â·þÎñÆ÷ÖªµÀÓÃʲô¶«Î÷Ì滻ռλ·ûÁË¡£
¶¨ÒåºÃsqlÓï¾äºÍ²ÎÊýºó¾ÍÊÇÖ´ÐÐÁË£¬Ö´ÐеÄʱºòÐèҪͬʱ½«sqlÓï¾äºÍ²ÎÊý´«È룬ÕâÑùÓû§ÊäÈëµÄ´øÓзǷ¨×Ö·ûµÄ×Ö·û´®ÔÚÊý¾Ý¿â»áµ±×÷²ÎÊý´¦Àí£¬¶ø²»»áµ±×÷sqlÓï¾äºÍÊý¾Ý¿â×Ô¼ºµÄ×Ö·û»ìÂÒ£¬·ÀÖ¹ÁË×¢Èë¹¥»÷¡£
    OracleCommand cmd = new OracleCommand();
     cmd.CommandText = strSQL;//¶¨ÒåoracleÃüÁîµÄÎı¾ÄÚÈÝ
      for(oracleParameter p in param)//½«²ÎÊý´«Èë
{
cmd.Parameters.Add(p);
}
     cmd.ExecuteNonQuery(); //Ö´ÐÐÃüÁî
 
ÉÏÃæ»ù±¾ÉÏÊÇÒ»¸öÍêÕûµÄ²ÎÊý»¯sql£¬²»Í¬µÄÊý¾Ý¿â·þÎñÆ÷sqlÓï¾äÖвÎÊýµÄռλ·û²»Í¬£¬ÉÏÃæÓõÄÊÇoracle£¬²ÎÊýռλ·ûÊÇðºÅ£¨£º£©¼ÓÃû×Ö£¬ÔÚsqlserverÖÐÊÇÓÃ@·ûºÅ¼ÓÃû×Ö×÷Ϊռλ·û£¬¶øÔÚmysqlÖÐÓÃÎʺţ¨£¿£©¼ÓÃû×ÖÀ´×÷Ϊ²ÎÊýռλ·û£¬²»Í¬µÄÊý¾Ý¿âÖвÎÊýµÄ±íʾ·ûºÅ²»Ò»Ñù£¬Õâ¸öÐèҪעÒâ¡£


Ïà¹ØÎĵµ£º

asp.net(C#)ʵÏÖSQL2000Êý¾Ý¿â±¸·ÝºÍ»¹Ô­

asp.net(C#)ʵÏÖSQL2000Êý¾Ý¿â±¸·ÝºÍ»¹Ô­
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.Htm ......

sqlµÝ¹é²éѯ

ÔÚ¹¤×÷ÖÐÓöµ½Ò»¸öÎÊÌâ,ÊÇÐèÒªsqlµÝ¹é²éѯµÄ.²»¶®,ÓÚÊǵ½csdnÉÏÈ¥ÎÊ,ÄÇÀïµÄЧÂÊÕæÊǷdz£¸ß,ÎÒÒÔǰҲûÔÚÉÏÃæÎʹýÎÊÌâ.
ÎÊÌâÃèÊö:
ÎÒÓÐÒ»¸ö±í½á¹¹ÈçÏÂ:
id upperid
1     2
3     2
4     1
5     3
¾ßÌå²ã´Î²»ÖªµÀ,ÎÒÏëÓõݹésqlÓ ......

C#ÓëSQL Server 2000ʵÏÖÎÞÏÞ¼¶²Ëµ¥


//tree.aspx.cs
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Syst ......

SQL Pivot & UnPivot

create table students (
  name varchar(25),
  class varchar(25),
  grade int
)
insert into students values ('ÕÅÈý','ÓïÎÄ',20)
insert into students values ('ÕÅÈý','Êýѧ',90)
insert into students values ('ÕÅÈý','Ó¢Óï',50)
insert into students values ('ÀîËÄ','ÓïÎÄ',81)
insert in ......

ʹÓÃSQLÓï¾ä

ʹÓÃSQLÓï¾ä
        SQLÓïÑÔ°üÀ¨Êý¾Ý²éѯÓïÑÔ(SELECT)¡¢Êý¾Ý²Ù×ÝÓïÑÔ(INSERT¡¢UPDATE¡¢DELETE)¡¢ÊÂÎñ¿ØÖÆÓïÑÔ(COMMIT¡¢ROLLBACK¡¢SAVEPOINT)¡¢Êý¾Ý¶¨ÒåÓïÑÔ(CREATE TABLE¡¢ALTER TABLE¡¢DROP)¡¢Êý¾Ý¿ØÖÆÓïÑÔ(GRANT¡¢REVOKE)µÈÎå¸ö²¿·Ö¡£
µ±±àдPL/SQLÓ¦ÓóÌÐòʱ£¬Ö»ÄÜÖ±½ÓǶÈëSELECT ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ