DelphiÁ¬½ÓSQL Server 2000
Ò»¡¢ÔÚDelphi7ÖÐÁ¬½ÓMS SQL Server 2000µÄ·½·¨¡£
¸Õ¿ªÊ¼Ê±½çÃæÈçÏ£ºÌí¼Ó4¸ö¿Ø¼þ¡£
ÉèÖÿؼþÊôÐÔ¹ý³Ì£º
1¡¢ADOConnection1ÉèÖÃ
1£©Ë«»÷ADOConnection1£¬½øÐÐÉèÖÃÁ¬½Ó×Ö·û´®£¨×÷ÓÃÊÇ£ºÑ¡È¡Á¬½ÓÇý¶¯·½Ê½ºÍÁ¬½ÓµÄÊý¾Ý¿âÉèÖã©¡£¹ý³ÌÈçÏÂͼËùʾ£º
2¡¢ADOQuery1ÉèÖãº
1£©ADOQuery1.connectionÊôÐÔΪADOConnection1;
2£©ADOQuery1.SQLÊôÐÔΪselect student.sno,sname,cname,grade from student,sc,course where student.sno=sc.sno and course.cno=sc.cno
3£©ADOQuery1.ActiveÉèÖÃΪTRUE¡£
3¡¢DataSource1ÉèÖÃ
DataSetÊôÐÔΪADOQuery1
4¡¢DBGrid1ÉèÖÃ
DataSourceÊôÐÔÉèÖÃΪDataSource1.
Ч¹ûͼ£º
¶þ¡¢Í¨¹ýDelphi7½øÐÐÉè¼ÆSQL²éѯµÄ½çÃæºÍ³ÌÐòʵÏÖ¡£
1¡¢½çÃæÉè¼Æ
Ìí¼ÓEdit£¬ButtonºÍLabel¿Ø¼þ£¬Èçͼ°Ú·ÅºÍÉèÖûù±¾ÊôÐÔ¡£
2¡¢ÔÚBitBtn1µÄClickʼþÄÚÍê³É³ÌÐò¡££¨Edit1ºÍEdit2µÄ×ۺϲéѯ£¬¹²4ÖÖÇé¿ö£©
procedure TForm1.BitBtn1Click(Sender: TObject);
var
i:integer;
SqlStr:String;
begin
i:=0;
if edit1.Text<>'' then
i:=i+1;
if edit2.Text<>'' then
i:=i+2;
case i of
0:
begin
SqlStr:='select student.sno,sname,cname,grade from student,sc,course '
+'where student.sno=sc.sno and course.cno=sc.cno ';
adoquery1.Close; //¹Ø±ÕADOQuery1£¬ÒÔ±ãÓÚ½øÐÐSQLÓï¾ä¸üÐÂ
adoquery1.SQL.Clear; //Çå¿ÕSQLÓï¾ä
adoquery1.SQL.Add(sqlStr); //Ìí¼ÓеÄSQL
adoquery1.Open; //ÐÂSQLÓÐЧ
end;
1:
begin
SqlStr:='select student.sno,sname,cname,grade from student,sc,course '
+'where student.sno=sc.sno and course.cno=sc.cno and sname='''+edit1.Text+'''';
adoquery1.Close; //¹Ø±ÕADOQuery1£¬ÒÔ±ãÓÚ½øÐÐSQLÓï¾ä¸üÐÂ
adoquery1.SQL.Clear; //Çå¿ÕSQLÓï¾ä
adoquery1.SQL.Add(sqlStr); //Ìí¼ÓеÄSQL
adoquery1.Open; //ÐÂSQLÓÐЧ
end;
2:
begin
SqlStr:='select student.sno,sname,cname,grade from student,sc,course '
+'where student.sno=sc.sno and course.cno=sc.cno and cname='''+edit2.Text+'''';
adoquery1.Close;
Ïà¹ØÎĵµ£º
--²éѯµ±Ç°Á¬½ÓµÄʵÀýÃû
select @@servername--²ì¿´ÈκÎÊý¾Ý¿âÊôÐÔ
sp_helpdb master
--ÉèÖõ¥Óû§Ä£Ê½£¬Í¬Ê±Á¢¼´¶Ï¿ªËùÓÐÓû§
alter database Northwind set single_user with rollback immediate--»Ö¸´Õý³£
alter database Northwind set multi_user
--²ì¿´Êý¾Ý¿âÊôÐÔ
sp_helpdb--²ì¿´Êý¾Ý¿â»Ö¸´Ä£Ê½
selec ......
---------Êýѧº¯Êý
1.¾ø¶ÔÖµ
S:select abs(-1) value
O:select abs(-1) value from dual
2.È¡Õû(´ó)
S:select ceiling(-1.001) value
O:select ceil(-1.001) value from dual
3.È¡Õû£¨Ð¡£©
S:select floor(-1.001) value
O:select floor(-1.001) value from dual
4.È¡Õû£¨½ØÈ¡£©
S:select cast ......
1. ˵Ã÷£º¸´ÖƱí(Ö»¸´Öƽṹ£¬Ô´±íÃû£ºa£¬Ð±íÃû£ºb)
SQL: select * into b from a where 1<>1;
2. ˵Ã÷£º¿½±´±í(¿½±´Êý¾Ý£¬Ô´±íÃû£ºa£¬Ä¿±ê±íÃû£ºb)
SQL: insert into b(a, b, c) select d, e, f from b;
&nb ......
½â¾ö°ì·¨£º
¿ªÊ¼->programs->MicroSoft SQL Server 2005->Configuration tools->SQL Server Configuration Manager
Ñ¡Ôñ SQL Server 2005 Network Configuartion-> Protocols for SQL ExpRESS ÔÙ Ñ¡Ôñ TCP/IP ÊôÐÔ ,Ñ¡ÔñIP Addresses
IP1 µÄ IP Address ÇëÈ·ÈÏÊÇ Äã·þÎñÆ÷µÄ IPµØÖ· £¬ Èç¹û· ......
SQLÔÚ½¨Á¢Óë·þÎñÆ÷µÄÁ¬½Óʱ³ö´íµÄ½â¾ö·½
ÔÚ½¨Á¢Óë·þÎñÆ÷µÄÁ¬½Óʱ³ö´í¡£ÔÚÁ¬½Óµ½ SQL Server 2005 ʱ£¬ÔÚĬÈϵÄÉèÖÃÏ SQL Server ²»ÔÊÐí½øÐÐÔ¶³ÌÁ¬½Ó¿ÉÄܻᵼÖ´Ëʧ°Ü¡£ (provider: ÃüÃû¹ÜµÀÌṩ³ÌÐò, error: 40 - ÎÞ·¨´ò¿ªµ½ SQL Server µÄÁ¬½Ó)
¸Õ¸Õ°²×°µÄÊý¾Ý¿âϵͳ£¬°´ÕÕÄ ......