贴上一个我的,可以参考着用Procedure FlashServerList(); Var StrSQL,Sv:String; tAdo:TADOConnection; tQuery: TADOQuery; Begin tAdo:=TAdoConnection.Create(nil); tQuery:=TAdoQuery.Create(nil);; tADO.LoginPrompt:=False; tAdo.ConnectionString:=MyConnectString; //SQL连接字符串 tQuery.Connection:=tAdo; StrSQL:='select DISTINCT server from mail order by server'; tQuery.SQL.Clear; tQuery.SQL.Add(StrSQl); tQuery.Open; while not tQuery.Recordset.EOF do Begin SV:=tQuery.Fields[0].asString; Form1.ListBox_Server.Items.Append(SV); tQuery.Next; End; tQuery.Close; tQuery.Destroy; tAdo.Close; tAdo.Destroy; End;
1.打开ADO控件页; 2.拖动一个ADOQuery组件到窗体上; 3.点击Object Inspector上的ConnectionString属性,右边会出现... 4.点击...后会出现数据连接属性对话界面,选择Microsoft OLE DB for SQL Server 5.然后下一步配置你的SQL Server服务器就可以了。
就OK了
---
晕了,,
Var StrSQL,Sv:String;
tAdo:TADOConnection;
tQuery: TADOQuery;
Begin
tAdo:=TAdoConnection.Create(nil);
tQuery:=TAdoQuery.Create(nil);; tADO.LoginPrompt:=False;
tAdo.ConnectionString:=MyConnectString; //SQL连接字符串
tQuery.Connection:=tAdo; StrSQL:='select DISTINCT server from mail order by server';
tQuery.SQL.Clear;
tQuery.SQL.Add(StrSQl);
tQuery.Open;
while not tQuery.Recordset.EOF do
Begin
SV:=tQuery.Fields[0].asString;
Form1.ListBox_Server.Items.Append(SV);
tQuery.Next;
End;
tQuery.Close;
tQuery.Destroy;
tAdo.Close;
tAdo.Destroy;
End;
2.拖动一个ADOQuery组件到窗体上;
3.点击Object Inspector上的ConnectionString属性,右边会出现...
4.点击...后会出现数据连接属性对话界面,选择Microsoft OLE DB for SQL Server
5.然后下一步配置你的SQL Server服务器就可以了。