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;
Ïà¹ØÎĵµ£º
ÍâÁ¬½ÓÈ¡Êý¾ÝÈç¹ûΪ¿Õ£¬²»´æÔÚASʱ¿ÉÄÜÈ¡µ½Êý¾Ý£¬µ«¼ÓÁËAS¾Í»á±¨´í¡£±ÈÈçSelect Top 10 a.*,b.Class AS ClassId
,b.DeviceName from AuxBusInfo a Left Join DeviceCandidate b On a.InitialDeviceRscId = b.DeviceRscId Order By AuxBusId£¬µ± ......
/*
select *,dbo.getDeptTree(id) as DeptTree from sysdept
µÝ¹éº¯Êý
*/
CREATE function getDeptTree(@NodeId int)
returns varchar(8000)
as
begin
declare @ret varchar(8000),@ParentId int,@len int
set @len = 0
&nb ......
Comparison of SQL and MDX Syntax
The Multidimensional Expressions (MDX) syntax is similar to the syntax of Structured Query Language (SQL). In many ways, the functionality supplied by MDX is also similar to that of SQL; with effort, you can eve ......
ROLLUP ÔËËã·ûÉú³ÉµÄ½á¹û¼¯ÀàËÆÓÚ CUBE ÔËËã·ûÉú³ÉµÄ½á¹û¼¯¡£ ÏÂÃæÊÇ CUBE ºÍ ROLLUP Ö®¼äµÄ¾ßÌåÇø±ð£º CUBE Éú³ÉµÄ½á¹û¼¯ÏÔʾÁËËùÑ¡ÁÐÖÐÖµµÄËùÓÐ×éºÏµÄ¾ÛºÏ¡£ ROLLUP Éú³ÉµÄ½á¹û¼¯ÏÔʾÁËËùÑ¡ÁÐÖÐÖµµÄijһ²ã´Î½á¹¹µÄ¾ÛºÏ¡£ ROLLUP Óŵ㣺 £¨£±£©ROLLUP ·µ»Øµ¥¸ö½á¹û¼¯£¬¶ø COMPUTE BY ·µ»Ø¶à¸ö½á ......
SQLÔÚ½¨Á¢Óë·þÎñÆ÷µÄÁ¬½Óʱ³ö´íµÄ½â¾ö·½
ÔÚ½¨Á¢Óë·þÎñÆ÷µÄÁ¬½Óʱ³ö´í¡£ÔÚÁ¬½Óµ½ SQL Server 2005 ʱ£¬ÔÚĬÈϵÄÉèÖÃÏ SQL Server ²»ÔÊÐí½øÐÐÔ¶³ÌÁ¬½Ó¿ÉÄܻᵼÖ´Ëʧ°Ü¡£ (provider: ÃüÃû¹ÜµÀÌṩ³ÌÐò, error: 40 - ÎÞ·¨´ò¿ªµ½ SQL Server µÄÁ¬½Ó)
¸Õ¸Õ°²×°µÄÊý¾Ý¿âϵͳ£¬°´ÕÕÄ ......