获取所有数据:function TFrmMain.SetMSSQLConn: Boolean;var StrUser, StrPw: string;begin Result := false; ADOConn.Connected := False ; if Trim(Edit1.Text) = '' then Edit1.Text := GetThisCompuerName(); (* ADOConn.ConnectionString := 'Provider=SQLOLEDB.1;Password=' + StrPw + ';Persist Security Info=True;User ID=' + StrUser + ';Data Source=' + Edit1.Text ; ADOConn.ConnectionString := 'Data Source=' + Edit1.Text + ';UID=' + StrUser + ';' + 'PWD=' + StrPw + ';' //+ 'Initial Catalog=PassportDB;' + 'Integrated Security=SSPI;' ; try ADOConn.Connected := True ; except Application.MessageBox('连接不成功!', '错误', MB_ICONERROR) ; Exit ; end ; *) if ChbMore.Checked then begin LoginName := EdtLogin.Text ; LoginPassword := EdtPw.Text ; end else begin LoginName := 'sa' ; LoginPassword := '' ; end ; DataComputerName := Edit1.Text; DataBaseName := 'master'; ADOConn.Connected := False ; {$IFDEF SQL2005} //连接SQL2005 ADOConn.ConnectionString := 'Provider=SQLOLEDB.1;server=' + DataComputerName + ';UID=' + LoginName + ';' + 'PWD=' + LoginPassword + ';' + 'Initial Catalog=' + DataBaseName + ';' + 'Integrated Security=SSPI;'; {$ELSE} ADOConn.ConnectionString := 'Provider=SQLOLEDB.1;Password=' + LoginPassword + ';Persist Security Info=false;User ID=' + LoginName + ';Data Source=' + DataComputerName + ';Initial Catalog=' + DataBaseName + ';'; {$ENDIF} try ADOConn.Connected := True ; except Application.MessageBox('不能获取数据库名称!', '错误', MB_ICONERROR) ; Exit ; end ; AdoqInfor.Connection := ADOConn ; //'SELECT name FROM sys.databases' ) then // {$IFDEF SQL2005} if not GetRequestData(AdoqInfor, 'SELECT name FROM sys.databases' ) then {$ELSE} if not GetRequestData(AdoqInfor, 'SELECT name FROM sysdatabases ') then //WHERE status = 16 WHERE suid IS NULL {$ENDIF} begin Application.MessageBox('不能获取数据库名称!', '错误', MB_ICONERROR) ; Exit ; end ; DataToComboBox(AdoqInfor, ComboBox1) ; Result := true;end;//表名ADOConn.GetTableNames(TableName);