asp.netÁ¬½ÓSQL ºÍACCESSÊý¾Ý¿â
ASP.NETÈçºÎÁ¬½ÓAccess»òSQL ServerÊý¾Ý¿â
Ê×ÏÈ¿´Ò»¸öÀý×Ó´úÂëƬ¶Ï:
³ÌÐò´úÂë:
--------------------------------------------------------------------------------
using System.Data;
using System.Data.OleDb;
......
string strConnection="Provider=Microsoft.Jet.OleDb.4.0;";
strConnection+=@"Data Source=C:\BegASPNET\Northwind.mdb";
OleDbConnection objConnection=new OleDbConnection(strConnection);
......
objConnection.Open();
objConnection.Close();
......
--------------------------------------------------------------------------------
½âÊÍ:
¡¡Á¬½ÓAccessÊý¾Ý¿âÐèÒªµ¼Èë¶îÍâµÄÃüÃû¿Õ¼ä,ËùÒÔÓÐÁË×îÇ°ÃæµÄÁ½ÌõusingÃüÁî,ÕâÊDZز»¿ÉÉÙµÄ!
¡¡strConnectionÕâ¸ö±äÁ¿Àï´æ·ÅµÄÊÇÁ¬½ÓÊý¾Ý¿âËùÐèÒªµÄÁ¬½Ó×Ö·û´®,ËûÖ¸¶¨ÁËҪʹÓõÄÊý¾ÝÌṩÕߺÍҪʹÓõÄÊý¾ÝÔ´.
¡¡"Provider=Microsoft.Jet.OleDb.4.0;"ÊÇÖ¸Êý¾ÝÌṩÕß,ÕâÀïʹÓõÄÊÇMicrosoft JetÒýÇæ,Ò²¾ÍÊÇAccessÖеÄÊý¾ÝÒýÇæ,asp.net¾ÍÊÇ¿¿Õâ¸öºÍAccessµÄÊý¾Ý¿âÁ¬½ÓµÄ.
¡¡"Data Source=C:\BegASPNET\Northwind.mdb"ÊÇÖ¸Ã÷Êý¾ÝÔ´µÄλÖÃ,ËûµÄ±ê×¼ÐÎʽÊÇ"Data Source=MyDrive:MyPath\MyFile.MDB".
ps:
¡¡1."+="ºóÃæµÄ"@"·ûºÅÊÇ·ÀÖ¹½«ºóÃæ×Ö·û´®ÖеÄ"\"½âÎöΪתÒå×Ö·û.
¡¡2.Èç¹ûÒªÁ¬½ÓµÄÊý¾Ý¿âÎļþºÍµ±Ç°ÎļþÔÚͬһ¸öĿ¼ÏÂ,»¹¿ÉÒÔʹÓÃÈçϵķ½·¨Á¬½Ó:
¡¡¡¡strConnection+="Data Source=";
¡¡¡¡strConnection+=MapPath("Northwind.mdb");
¡¡¡¡ÕâÑù¾Í¿ÉÒÔÊ¡µÃÄãдһ´ó¶Ñ¶«Î÷ÁË!
¡¡3.ҪעÒâÁ¬½Ó×Ö·û´®ÖеIJÎÊýÖ®¼äÒªÓ÷ֺÅÀ´·Ö¸ô.
¡¡"OleDbConnection objConnection=new OleDbConnection(strConnection);"ÕâÒ»¾äÊÇÀûÓö¨ÒåºÃµÄÁ¬½Ó×Ö·û´®À´½¨Á¢ÁËÒ»¸öÁ´½Ó¶ÔÏó,ÒÔºó¶ÔÊý¾Ý¿âµÄ²Ù×÷ÎÒÃǶ¼ÒªºÍÕâ¸ö¶ÔÏó´ò½»µÀ.
¡¡"objConnection.Open();"ÕâÓÃÀ´´ò¿ªÁ¬½Ó.ÖÁ´Ë,ÓëAccessÊý¾Ý¿âµÄÁ¬½ÓÍê³É.ÆäÓà²Ù×÷(²åÈë,ɾ³ý...)Çë²ÎÔÄÏà¹ØÊé¼®
Á¬½ÓSQL Server
Àý×Ó´úÂëƬ¶Ï:
³ÌÐò´úÂë:
--------------------------------------------------------------------------------
ÍøÒ³½ÌѧÍø
using System.Data;
using System.Data.SqlClient;
...
string strConnection="user id=sa;password=;";
strConnection+="initial catalog=Northwind;Server=YourSQLServer;";
strConnection+="Connect Timeout=30";
SqlConne
Ïà¹ØÎĵµ£º
CONVERTµÄʹÓ÷½·¨:
¡¡¡¡¸ñʽ:
¡¡¡¡CONVERT(data_type,expression[,style])
¡¡¡¡ËµÃ÷:
¡¡¡¡´ËÑùʽһ°ãÔÚʱ¼äÀàÐÍ(datetime,smalldatetime)Óë×Ö·û´®ÀàÐÍ(nchar,nvarchar,char,varchar)
¡¡¡¡Ï໥ת»»µÄʱºò²ÅÓõ½.
¡¡¡¡Àý×Ó:
¡¡¡¡Select CONVERT(varchar(30),getdate(),101) now
¡¡¡¡½á¹ûΪ
¡¡¡¡now
¡¡¡¡ ......
ÔÚSQLÓï¾äÓÅ»¯¹ý³ÌÖУ¬ÎÒÃǾ³£»áÓõ½hint,ÏÖ×ܽáÒ»ÏÂÔÚSQLÓÅ»¯¹ý³ÌÖг£¼ûOracle HINTµÄÓ÷¨£º
1. /*+ALL_ROWS*/
±íÃ÷¶ÔÓï¾ä¿éÑ¡Ôñ»ùÓÚ¿ªÏúµÄÓÅ»¯·½·¨,²¢»ñµÃ×î¼ÑÍÌÍÂÁ¿,ʹ×ÊÔ´ÏûºÄ×îС»¯.
ÀýÈç:
SELECT /*+ALL+_ROWS*/ EMP_NO,EMP_NAM,DAT_IN from BSEMPMS WHERE EMP_NO='SCOTT';
2. /*+FIRST_ROWS*/
±íÃ÷¶ÔÓï¾ä¿éÑ ......
¼Æ»®ÓÚ2008ÄêµÚÒ»¼¾¶È·¢²¼µÄSQL Server 2008²»½ö¶ÔÔÓÐÐÔÄܽøÐÐÁ˸Ľø£¬»¹Ìí¼ÓÁËÐí¶àÐÂÌØÐÔ£¬±ÈÈçÐÂÌíÁËÊý¾Ý¼¯³É¹¦ÄÜ£¬¸Ä½øÁË·ÖÎö·þÎñ£¬±¨¸æ·þÎñ£¬ÒÔ¼°Office¼¯³ÉµÈµÈ¡£
¡¡¡¡SQL Server¼¯³É·þÎñ
¡¡¡¡SSIS(SQL Server¼¯³É·þÎñ)ÊÇÒ»¸öǶÈëʽӦÓóÌÐò£¬ÓÃÓÚ¿ª·¢ºÍÖ´ÐÐETL(½âѹËõ¡¢×ª»»ºÍ¼ÓÔØ)°ü¡£SSIS´úÌæÁËSQL 2000µÄDTS¡£Õ ......
¼Æ»®ÓÚ2008ÄêµÚÒ»¼¾¶È·¢²¼µÄSQL Server 2008²»½ö¶ÔÔÓÐÐÔÄܽøÐÐÁ˸Ľø£¬»¹Ìí¼ÓÁËÐí¶àÐÂÌØÐÔ£¬±ÈÈçÐÂÌíÁËÊý¾Ý¼¯³É¹¦ÄÜ£¬¸Ä½øÁË·ÖÎö·þÎñ£¬±¨¸æ·þÎñ£¬ÒÔ¼°Office¼¯³ÉµÈµÈ¡£
¡¡¡¡SQL Server¼¯³É·þÎñ
¡¡¡¡SSIS(SQL Server¼¯³É·þÎñ)ÊÇÒ»¸öǶÈëʽӦÓóÌÐò£¬ÓÃÓÚ¿ª·¢ºÍÖ´ÐÐETL(½âѹËõ¡¢×ª»»ºÍ¼ÓÔØ)°ü¡£SSIS´úÌæÁËSQL 2000µÄDTS¡£Õ ......
1:replace º¯Êý
µÚÒ»¸ö²ÎÊýÄãµÄ×Ö·û´®£¬µÚ¶þ¸ö²ÎÊýÄãÏëÌæ»»µÄ²¿·Ö£¬µÚÈý¸ö²ÎÊýÄãÒªÌæ»»³Éʲô
select replace('lihan','a','b')
-----------------------------
lihbn
£¨ËùÓ°ÏìµÄÐÐÊýΪ 1 ÐУ©
============================================== ......