DelphiʹÓÃiniÅäÖÃÎļþÁ¬½ÓMS SQLÊý¾Ý¿â
ºÜÔç×ö¹ýµÄÒ»¸ödelphiÏîÄ¿£¬°ÑÀïÃæÓõ½µÄ¼¼Êõ×ܽáһϣ¬Ö÷ÒªÊÇÕë¶ÔÏóÎÒÕâÑùµÄdelphiÐÂÊÖ£¬¼¼ÊõÉÏ×ö¸ö»ýÀÛ°É£¡
¼ÙÉèÎÒÃǵÄÊý¾Ý¿âÅäÖÃÎļþServerInfo.iniÄÚÈÝÈçÏ£º
[ServerInfo]
ServerIP=192.168.1.5
SQLDBName=Data
SQLUserID=sa
SQLPwd=
ÎÒÃǶ¨ÒåÒ»¸öÁ¬½ÓÊý¾Ý¿âµÄ¹ý³ÌDBConnectÄÚÈÝÓ¦ÈçÏÂ
procedure TDM.DBConnect();
var
ini:TiniFile;
Server,User,Pass,DBName:string;
begin
ini := TiniFile.Create(ExtractFilePath(Application.ExeName)+'dbconn.ini'); //³õʼ»¯iniÎļþ
Server := ini.ReadString('serverinfo','ServerIP',''); //Êý¾Ý¿âipµØÖ·
DBName := ini.ReadString('serverinfo','SQLDBName',''); //Êý¾Ý¿âÃû
User := ini.ReadString('serverinfo','SQLUserID',''); //Êý¾Ý¿âÓû§Ãû
Pass := ini.ReadString('serverinfo','SQLPwd',''); //Êý¾Ý¿âÃÜÂë
try
DM.ADOConn.ConnectionString := 'Provider=SQLOLEDB.1;Persist Security Info=False;'
+'User ID='+trim(User)
+';Password='+trim(Pass)
+';Initial Catalog='+trim(DB)
+';Data Source='+trim(Server);
DM.ADOConn.Open ;
except
application.MessageBox('Êý¾Ý¿âÁ¬½Óʧ°Ü£¬Çë¼ì²éINIÅäÖÃÎļþ','Ìáʾ',64);
application.Terminate ;
end;
end;
ÏàÐÅ´ó¼Ò¶¼ÄÜ¿´¶®£¬×¢ÒâʹÓÃTiniFileÀàµÄº¯Êý»ò¹ý³ÌÓ¦ÒýÈëINIFilesµ¥Ôª¡£
Ïà¹ØÎĵµ£º
SQL×¢Èë¹¥»÷
¡¡¡¡SQL×¢Èë¹¥»÷ÊǺڿͶÔÊý¾Ý¿â½øÐй¥»÷µÄ³£ÓÃÊÖ¶ÎÖ®Ò»¡£Ëæ×ÅB/SģʽӦÓÿª·¢µÄ·¢Õ¹£¬Ê¹ÓÃÕâÖÖģʽ±àдӦÓóÌÐòµÄ³ÌÐòÔ±Ò²Ô½À´Ô½¶à¡£µ«ÊÇÓÉÓÚ³ÌÐòÔ±µÄˮƽ¼°¾ÑéÒ²²Î²î²»Æ룬Ï൱´óÒ»²¿·Ö³ÌÐòÔ±ÔÚ±àд´úÂëµÄʱºò£¬Ã»ÓжÔÓû§ÊäÈëÊý¾ÝµÄºÏ·¨ÐÔ½øÐÐÅжϣ¬Ê¹Ó¦ÓóÌÐò´æÔÚ°²È«Òþ»¼¡£Óû§¿ÉÒÔÌá½»Ò»¶ÎÊý¾Ý¿â²éѯ´ú ......
¾Û¼¯Ë÷Òý²»½ö°üº¬Ë÷ÒýµÄkeyÖµ£¬»¹°üº¬±íÊý¾Ý£»
·Ç¾Û¼¯Ë÷ÒýÖ»°üº¬Ë÷ÒýµÄkeyÖµ¡£
SQL ServerÔÚÓÐЩÇé¿öÏ£¬Óоۼ¯Ë÷ÒýºÍ·Ç¾Û¼¯Ë÷Òý´æÔÚʱ£¬»áÑ¡Ôñ×߷Ǿۼ¯Ë÷Òý£¬¶ø²»×ß¾Û¼¯Ë÷Òý¡£
Àý×ÓÈçÏ£º
ÔÚ SQL Server µÄadventureWorksÊý¾Ý¿âÏ£¬ÔËÐÐÈçÏÂÓï¾ä£º
select DepartmentID,Name from HumanResources.Department
Departm ......
ÔÚÍøÉÏ¿´µ½Ò»¸öºÜºÃµÄÀý×Ó½²½âinºÍexistsµÄÇø±ð£¬ÕâÀﱸÍüÏ¡£
±¾Ê¾ÀýËùʾ²éѯ²éÕÒÓÉλÓÚÒÔ×Öĸ B ¿ªÍ·µÄ³ÇÊÐÖеÄÈÎÒ»³ö°æÉ̳ö°æµÄÊéÃû£º
USE pubs
SELECT title
from titles WHERE EXISTS
(SELECT *
from publishers
WHERE pub_id = titles.pub_id ......
²Ù
×÷ϵͳµÄÖ§³Ö
°æ
±¾ºÍ·¢Ðаæ
ʵ
Àý¡¢Êý¾Ý¿âºÍ±í¿Õ¼ä
ʵ
ÀýÃûºÍSID
ϵ
ͳÊý¾Ý¿âºÍϵͳ±í¿Õ¼ä
±¾ÒëÎIJÉÓÃ֪ʶ¹²ÏíÊð
Ãû-·ÇÉÌÒµÐÔʹÓÃ-Ïàͬ·½Ê½¹²Ïí 3.0 UnportedÐí¿ÉÐÒé
·¢²¼£¬×ªÔØÇë±£Áô´ËÐÅÏ¢
ÒëÕߣºÂí³ÝÜÈ | Á´½Ó£ºhttp://www.dbabeta.com/2010/oracle-sql-server-comparison-i.html
×÷ÕߣºS ......