ÍƼö£ºSQL Serverµ¥ÒýºÅÁ½ÖÖ´¦Àí¼¼ÇÉ
ºÍÊý¾Ý¿â´ò½»µÀҪƵ·±µØÓõ½SQLÓï¾ä£¬³ý·ÇÄãÊÇÈ«²¿Óÿؼþ°ó¶¨µÄ·½Ê½£¬µ«²ÉÓÿؼþ°ó¶¨µÄ·½Ê½´æÔÚ×ÅÁé»îÐԲЧÂʵ͡¢¹¦ÄÜÈõµÈµÈȱµã¡£Òò´Ë£¬´ó¶àÊýµÄ³ÌÐòÔ±¼«ÉÙ»ò½ÏÉÙÓÃÕâÖְ󶨵ķ½Ê½¡£¶ø²ÉÓ÷ǰ󶨷½Ê½Ê±Ðí¶à³ÌÐòÔ±´ó¶¼ºöÂÔÁ˶Ե¥ÒýºÅµÄÌØÊâ´¦Àí£¬Ò»µ©SQLÓï¾äµÄ²éѯÌõ¼þµÄ±äÁ¿Óе¥ÒýºÅ³öÏÖ£¬Êý¾Ý¿âÒýÇæ¾Í»á±¨´íÖ¸³öSQLÓï·¨²»¶Ô£¬±¾ÈË·¢ÏÖÓÐÁ½ÖÖ·½·¨¿ÉÒÔ½â¾öºÍ´¦ÀíÕâÖÖµ¥ÒýºÅµÄÎÊÌ⣨ÒÔVBΪÀý×Ó£©¡£
·½·¨Ò»£º
ÀûÓÃתÒå×Ö·û´¦ÀíSQLÓï¾ä¡£ÏÂÃæµÄº¯Êý¿ÉÒÔÔÚÖ´ÐÐSQLÓï¾äÇ°µ÷ÓÃ,Ö´Ðд¦ÀíºóµÄ½á¹û¼´¿É²úÉúÕýÈ·µÄ½á¹û¡£
Function ProcessStr(str As String)
Dim pos As Integer
Dim stedest As String
pos = InStr(str, "'")
While pos > 0
str = Mid(str, 1, pos) & "'" & Mid(str, pos + 1)
pos = InStr(pos + 2, str, "'")
Wend
ProcessStr = str
End Function
ÆäÖÐstr²ÎÊýÊÇÄãµÄSQL×Ö·û´®¡£º¯ÊýÒ»µ©·¢ÏÖ×Ö·û´®ÖÐÓе¥ÒýºÅ³öÏÖ£¬¾ÍÔÚÇ°Ãæ²¹ÉÏÒ»¸öµ¥ÒýºÅ¡£
·½·¨¶þ£º
ÀûÓÃÊý¾Ý¶ÔÏóÖеIJÎÊý¡£¿ÉÒÔÀûÓÃADODB.COMMAND¶ÔÏ󣬰Ѻ¬Óе¥ÒýºÅµÄ×Ö·û´®´«µÝ¸øCOMMAND£¬È»ºóÖ´ÐвéѯµÈ²Ù×÷¼´¿É¡£
ÒÔÉÏÁ½ÖÖ·½·¨±È½Ï£¬·½·¨Ò»Ôö¼ÓÁËϵͳ´¦Àíʱ¼ä£¬·½·¨¶þ¼ò½à¡¢¸ßЧ£¬Èç¹û²ÉÓô洢¹ý³Ì£¬È»ºóÔÙ´«µÝ²ÎÊý¸ø´æ´¢¹ý³Ì£¬´æ´¢¹ý³ÌÊÇÔ¤±àÒëµÄ£¬ÕâÑùϵͳµÄЧÂʸü¸ß¡£
ÏÂÃæ¾Í¾ÙÀý×Ó¼ÓÒÔ˵Ã÷¡£
н¨Ò»¸öÏîÄ¿£¬ÏîÄ¿ÖÐÓÐÒ»¸ö´°Ì壨Form1£©£¬Á½¸öÃüÁî°´Å¥£¬Ò»¸öMSFlexGrid£¬Ãû³Æ·Ö±ðΪ£ºCommand1£¬Command2£¬MSFlexGrid1,Ò»¸öCOMBOX£¨COMBO1£©£¬ËüµÄÄÚÈÝÔ¤ÏÈÉ趨Ϊ“Paolo'f”¡¢“Paolo'f”¡£Command1ÑÝʾ·½·¨Ò»£¬Command2ÑÝʾ·½·¨¶þ£¬MSFlexGrid1´æ´¢·½·¨¶þ²éѯ(SELECT)½á¹û¡£¶ÔÓÚÆäËûµÄSQL²Ù×÷£¨INSERT¡¢DELTER¡¢UPDATAE£©·½·¨¼«ÎªÀàËÆ£¬±ÊÕ߾Ͳ»ÔÙ׸Êö¡£Àý×ÓÖÐÓõ½SQL SERVERÖеÄPUBSÊý¾Ý¿âÖеÄEMPLOYEE±í£¬Í¬Ê±¿ÉÒÔÓÃSQLÓï·¨°ÑÆäÖÐÁ½Ìõ¼Ç¼ÖеÄFNAME¸ÄΪ“Paolo''f”¡¢“Paolo'f”¡£ SQLÓï·¨ÈçÏ£º
update employee set fname=" Paolo''''f"
where emp_id='PMA42628M'
update employee set fname=" Paolo''f"
where emp_id='PMA42628M'
³ÌÐòÈçÏ£º
Ê×ÏÈ°ÑÇ°ÃæµÄº¯Êý¼ÓÈë¡£ÔÚ´°ÌåµÄͨÓÃÖÐÉùÃ÷ÈçϱäÁ¿£º
Dim cnn1 As ADODB.Connection 'Á¬½Ó
Dim mycommand As ADODB.Command 'ÃüÁî
Dim rstByQuery As ADODB.Recordset '½á¹û¼¯
Dim strCnn As String 'Á¬½Ó×Ö·û´®
Private Sub Form_Load()
Set cnn
Ïà¹ØÎĵµ£º
create PROCEDURE pagelist
@tablename nvarchar(50),
@fieldname nvarchar(50)='*',
@pagesize int output,--ÿҳÏÔʾ¼Ç¼ÌõÊý
@currentpage int output,--µÚ¼¸Ò³
@orderid nvarchar(50),--Ö÷¼üÅÅÐò
@sort int,--ÅÅÐò·½Ê½£¬1±íʾÉýÐò£¬0±íʾ½µÐòÅÅÁÐ
......
Êý¾Ý¶¨ÒåÓïÑÔ£¨DDL£©£º
1£©´´½¨Êý¾Ý¿â£¨create£©£ºcreate database database-name;
eg. create database test;
2£©É¾³ýÊý¾Ý¿â£ºdrop database dbname;
& ......
Õâ¾ÍÒª´ÓË«ÒýºÅºÍµ¥ÒýºÅµÄ×÷Óý²Æð£º
Ë«ÒýºÅÀïÃæµÄ×ֶλᾹý±àÒëÆ÷½âÊÍÈ»ºóÔÙµ±×÷HTML´úÂëÊä³ö£¬µ«Êǵ¥ÒýºÅÀïÃæµÄ²»ÐèÒª½âÊÍ£¬Ö±½ÓÊä³ö¡£ÀýÈ磺
$abc='I love u';
echo $abc //½á¹ûÊÇ:I love u
echo '$abc' //½á¹ûÊ ......
insert into mysql.user
SELECT '%', 'admin', PASSWORD('admin'), Select_priv, Insert_priv, Update_priv,
Delete_priv, Create_priv, Drop_priv, Reload_priv,
Shutdown_priv, Process_priv, File_priv, Grant_priv, References_priv,
Index_priv, Alter_priv, Show_db_priv, Super_priv, ......
Çé¾°Ò»£º
±íÖÐÊý¾Ý
name score
aaa 11
aaa 19
bbb 12
bbb 18
ccc 19
ddd 21
ÆÚÍû²éѯ½á¹ûÈçÏÂ
name score
aaa 30
bbb   ......