Presentation is loading. Please wait.

Presentation is loading. Please wait.

Publishing Your PDB Under Windows

Similar presentations

Presentation on theme: "Publishing Your PDB Under Windows"— Presentation transcript:

1 Publishing Your PDB Under Windows
Jim Quigley conEdison

2 T

3 Introduction Tutorial
How to publish the contents of a database using features available in Microsoft Windows Local machine Legacy client/server Intranet/Internet PDB or other SAS is dbms in all samples Oracle/Sybase, access & sql server in ms doc Leagcy – app runs in window on client, database on server. (fat client)

4 Introduction “Might be a little bit heavy on the VB/ HTML side for old-time capacity planners...” Vic Soder, CMG ERB If you have ever written a COBOL program, you are overqualified for web development. Everlybody has different “web” experience. Cover a lot of ground web develepoer coding vb for 10 years and design web sites nothing new till last 20 minutes if your editor is spf ir vi then we will be covering a lot of ground not a code review - discus what you can do if you take he time to wrapsome script around these powerfull objects

5 Disclaimer All products mentioned are the property of their owners
It may possible to use these technologies to publish data in ways that were not intended, or that have licensing implications Everbody does this, but take it further SAS & MS Have no interest or affiliation, financial or otherwise Traditional client server –one server license and a dozen client license Put in on out Intranet – they wanted us to pay for 10,000 clients Not MS or IBM… ado/rds - sas has their own progucts in this space - support i s a business decision SAS/MMDB (Milti-Dimentional DataBase) IOM SAS/Share SAS/Access Interface to ODBC

6 Agenda Scripting Data Access Methods ActiveX Controls Overview
Configuration Issues Sample Scripts ActiveX Controls Office Web Components Script - briefly

7 Scripting

8 Scripting Script is the glue Vbscript and Jscript
Legacy Windows WSH – Windows Scripting Host Browser Client-side and Server-side Can use VB or VC of course, but we will concentrate on Vbscript because it is directly portable between Windows window and the browser easy not compiled – exec from ascii Compelling – get so much done with just a few lines Mix-n-match Both vbs and htm directly “clickable” under windows…Until 5/4 you could run vbs wih a click iloveyou

9 Scripting SAS M Browser T D I A V C E X SQL Script Server Window
Access Window Browser M D A C Script T I V E X vsam-cobol-cics map BMS File control / terminal control Visual controls

10 Microsoft Data Access Components
MDAC Microsoft Data Access Components

11 MDAC Universal Data Access ODBC – Open Database Connectivity
OLE DB – OLE Database ADO – Active Data Objects RDS – Remote Data Services ADO.Net - ??? Hierarchy DB Lib, RDO

12 MDAC MSDASQL MS OleDb provider for ODBC -
If ODBC then all except non-sql

13 ODBC Circa 1990 Ubiquitous drivers Not an Object-Oriented API
Relational bias Any repository worth it’s salt has an odbc driver Bias not an issue if your data is supported A ton of apps out there rely on ODBC, and OleDb not available for all – SAS only with V8

14 OLE DB COM interface Support for broader spectrum of data repositories
Interface used by ADO ODBC data sources accessible via “MS OLE DB provider for ODBC” Possibly with reduced function ole db = tabular ADO requirement more powerful – MSDASQL raises OCBC, but not all ole db features supported Component Object Model

15 ADO (currently) Highest level interface Simplified object structure
Relies on OLE DB Only need to define one object No need to keep track of cursors an handles and the like

16 RDS Makes ADO data sources accessible across a network
HTTP, HTTPS, or DCOM Uses Microsoft Internet Information Server as conduit Q MSADC Properties in IIS manager , Directory Security, "IP Address and Domain Name Restrictions"

17 RDS Requesting & serving processes can be on different machines
MIME, not XML Multipurpose Internet Mail Extension (MIME)

18 MDAC Configuration Issues
Gotchas -

19 ODBC Data Sources Control Panel Administrative Tools Data Sources (ODBC) SAS ODBC Drivers System Data Source TCP Port c:\WINNT\system32\drivers\etc\services Win200, elsewhere in other Win version SAS doc good, but System dsn = data access occurs under the control of processes running with different credentials DDE no longer supported after V7 TCP Port – “you may need to …”

20 SAS TCP Port It took me a long time to get this stuff working, which is precicely why I’m talking about it No sense Reinventing the wheel

21 SAS ODBC vs. OLE DB OLE DB ODBC Auto install with V8 Separate install
SQL not supported Direct lib/member access Field name is variable name ODBC Separate install Full SQL support Runs Proc OdbcServ instance Field name is variable label There are some small holes in SAS compatibility with MDAC Work in progress Mr. Goodnight stands to be one of the wealthies men in America following the IPO Documentation D:\Program Files\SAS Institute\Shared Files\SAS OLE DB Data Providers\sasafbas.dll .chm

22 MSDFMAP.ini RDS Security C:\WinNT\System\MSDFMAP.ini
Create token to identify local data source for remote access Determine permitted access Can’t make it too easy - Wouldn’t be good it I could read any database on your system Not hard to see that RDS could pose a security risk Shipped with no access – only to Microsoft samples Malicious person might… Determines which data sources can be accessed remotely and how Which sql statements, even Specific sql – like stored procdures SP1 will replace msdfmap.ini

23 MSDFMAP.ini This was the knottiest problem

24 MSDFMAP.ini [connect default] Access=NoAccess [sql default] ;Sql=" “ ' <---comment this line out [connect PDB] Access=ReadOnly Connect="Provider=sas.LocalProvider.1; Data Source=d:\PDB\Detail\“ [connect SasRemote] Access=ReadOnly Connect="Data Source=SasLocal" Some useful comments and connect sections that enable samples TechNet – though I’m still not motivated keyword/value pair

25 Other RDS/IIS Issues IIS uses IWAM-servername as proxy (Launch IIS Process Account) WQExxxxx.TRC diagnostics Recommendations (SAS) ODBC – Start Proc OdbcServ manually OLE DB – give IWAM-servername read permission to PDB ODBC – start Proc OdbcServ if not already running Stop with wmi Start with libname list

26 MDAC Interfaces How do write script to use the MDAC

27 ADO Objects

28 RecordSet Object Set rs = CreateObject(“ADODB.Recordset”) Methods
rs.Open, rs.Close rs.MoveFirst, Rs.MoveNext Properties rs.BOF, rs.EOF rs.Connection Open DCB Methods – Put/Get Properties – Lrecl/Blksize/Recfm Methods – subroutines DSECT – readtcb

29 Field Object Fields collection contains Field objects, one for each column in the table rs.Fields.Count – number of columns rs.Fields(x).Value - value rs.Fields(x).Name – label Count is single instance Lots of other MetaData data type, precision, formatting…

30 Warning Code to Follow

31 ADO Script - WSH Set rs = CreateObject(“ADODB.Recordset”) ConnectionString = “DSN=SasLocal” Sql = “Select PCTCPUTM from PDB.System” rs.Open Sql, ConnectionString While Not rs.EOF Msg = Msg + CStr(rs.Fields(0).Value) + vbCrLf rs.MoveNext end MsgBox Msg D:\Cmg2000\AdoWsh.vbs Create an instance of - Instantiate the recordset object ConnectionString – reference to the ODBC DSN token or OleDb version (later) Sql – arbitrary, depends on support in driver Open – where the action occurs – where error handling should be… In absence of error handling a msgbox should pop up Standard VB Err object or Errors object attached to the Connection Object After open no error correction in samples

32 RDS Script - WSH Set rs = CreateObject("ADODB.Recordset") ConnectionString = “Provider=MS Remote;” + _ “Remote Server= + _ “Handler=MSDFMAP.Handler;”+ _ “Data Source=SasRemote” Sql = “Select PCTCPUTM from PDB.System“ rs.Open Sql, ConnectionString While Not rs.EOF Msg = Msg + CStr(rs.Fields(0).Value) + vbCrLf rs.MoveNext end MsgBox Msg D:\Cmg2000\RdsWsh.vbs Over inter/intranet – to some data source to which you don’t otherwise have access Internet – security considerations Use MS.Remote provider to go to Remote Server to access the DataSource defined to the MSDFMAP handler

33 ADO Script – Client-Side
<HTML> <SCRIPT LANGUAGE=vbscript> Set rs = CreateObject("ADODB.Recordset") ConnectionString = "DSN=SasLocal“ Sql = “Select PCTCPUTM from PDB.System“ rs.Open Sql, ConnectionString While Not rs.EOF Msg = Msg + rs.Fields(0).Value + vbCrLf rs.MoveNext end MsgBox Msg </SCRIPT> </HTML> D:\Cmg2000\AdoClient.htm Same with RDS Client side or serve side script Options – server

34 ADO Script – Server-Side
<HTML> <% Set rs = CreateObject("ADODB.Recordset") ConnectionString = "Data Source=SasLocal“ Sql = "Select PCTCPUTM from PDB.System“ rs.Open Sql, ConnectionString Response.Write("<SELECT>" + vbCrLf) While Not rs.EOF str = "<OPTION>" + CStr(rs.Fields(0).Value) + vbCrLf Response.Write(str) rs.MoveNext Wend %> </OPTION></SELECT> </HTML> Percent signs delimit script – otherwise pretty much the same thing we have been doing Can’t produce client msgbox on server If you don’t understand why chew on it and grab me during the week

35 ADO Script Options Access Type Script Method Access Method
Local Machine WSH or Client-Side Any Client / Server RDS or OLE DB Intranet UNC Accessible Client-Side Internet Server-Side Don’t like this slide – Took a crack – need bigger matrix Asdf – unc on separate row Where is the data in relation to the clients Do the clients have the software to access the data Do the clients have a network connection to the data - Can you see it in Explorer Do the clients have a network connection to the server Firewall considerations not withstanding Local machine is like the samples Not all options * Most popular and where you should be to use ActiveX features to come

36 ActiveX Objects

37 ActiveX Objects COM subroutines Visible and not Microsoft and not
ProgId (OWC.Spreadsheet) or ClassId “0002E C ” Create them Read/write properties Call methods Handle events Component Object Model - Standard, OLE, VBX Small number of native objects - Anything more than a drop=down list then build it yourself from windows primatives, which was/is tedious API/Protocol exposes entry points to respond to prescribed calls Logon/iDispatch Ever coded, or familiar with the structure of a VTAM app, instantiate when you open the APPLID wait for events like logon exit 1982 – macro-level CICS in assembler data streams or-ing bits into attribute bytes to protect and highlight fields Windows development was complex Instantiate and handle events Visible & not – TreeView To a large degree, What makes windows apps recognizable & intuitive GUID 32-byte globally unique Dll, OCX Drag n drop in VB and VID (Front Page?) both visual ActiveX controls (such as spin buttons) and nonvisual ActiveX components (such as database access objects). It's hard to find a significant Visual Basic program that doesn't make heavy use of premade reusable components that game we played in college, "i can write it in x lines", LISP and APL guys always won


39 ActiveX – No Script <HTML> <OBJECT HEIGHT=500 WIDTH=100% classid=clsid:C4D2D8E0-D1DD-11CE-940F > </OBJECT> </HTML> D:\Cmg2000\NoScript.htm Development environment will ley you work with ProId, ClassIdd GUID otherwise Since we are all performance analysts…

40 ActiveX – Data Bound <HTML> <OBJECT id=grid height=600 width=100% classid=clsid:0ECD9B64-23AA-11D0-B351-00A0C9055D8E> </OBJECT> <SCRIPT LANGUAGE=vbscript> Set rs = CreateObject("ADODB.Recordset") Set cn = CreateObject("ADODB.Connection") cn.Open "Provider=sas.LocalProvider.1;Data Source=d:\PDB\“ rs.Open “System", cn, , , 512 'adCmdTableDirect set grid.DataSource = rs </SCRIPT> </HTML> D:\Cmg2000\DataBound.htm OLE DB MSHierarchicalFlexGridLib.MSHFlexGrid Paper samples are ODBC. html ~ script/dcf/gml

41 Microsoft Office Web Components

42 Office Web Components Ship with Office 2000 c:\Program Files\MicrosoftOffice\Office\MsOwc.dll Spreadsheet clsid:0002E C ProgId = OWC.Spreadsheet Chart clsid:0002E C ProgId = OWC.Chart Pivot Table - OWC.PivotTable DSC - OWC.DataSourceControl Pivot Table – Proc Summary – data reduction The Office Web Components are an option on the Office 2000 install. It is also possible to install them from a link on a web page by including a ASDF tag pointing to the OWC .cab file. You can place the OWC cab file on a share, and use the CODEBASE parameter in the object tag to automatically install the components for the user. Though, licensing requires that they are actually licensed to use Office 2000.

43 OWC Spreadsheet Resembles Excel spreadsheet Visible or not
Contains one or more Worksheets Worksheets contain cells spreadsheet.worksheet.Cell(row,col) Single Worksheet then spreadsheet.Cell(row,col) OWC spreadsheet - it's the real thing – all the basic stuff The more you work with it the more that you find missing… Recalculation engine forecast, trend, correlation, regression… Copy columns or transfer the contents of an entire spreadsheet to an excel worksheet Hundreds of objects/methods/properties Invisible calculation engine – forecasting functions ..- but not word wrap (adjust height of columns Only sort by one column

44 OWC Spreadsheet Range Identifies a rectangular group of cells
Used by methods that operate on groups of cells set Range = spreadsheet.Columns(x) object.Range(TopLeft : BottomRight) Single cell, row, column or anything you could select with mouse back in the early 80's it was RAMIS, now if it isn't in an Excel spreadsheet then it really doesn't exist

45 OWC Spreadsheet API ss.ActiveSheet.UsedRange.Clear
ss.ViewableRange = ss.ActiveSheet.UsedRange.Address ExcelStyleCellReference = ss.Columns(Columns).Address Set c = ss.Constants Constants available at run-time rHeaders.HAlignment = c.ssHAlignCenter ss.ActiveSheet.Rows(FirstDataLine).Borders.Weight = owcLineWeightMedium Set Cell = ss.ActiveSheet.Cells Cell(y,x).Value = rs.Fields(x).Value

46 OWC Spreadsheet Formatting
ss.TitleBar.Caption = “string" ss.Columns.ColumnWidth = 100 ss.Rows(x).Font.Bold = True range.NumberFormat = "hh:mm“ ss.Columns(x).Hidden = True ss.DisplayRowHeaders = False ss.ScreenUpdating = False ss.Rows(x).RowHeight = 55 ss.DisplayColHeaders = False

47 Populate Spreadsheet from RecordSet
Row = 1 While Not rs.EOF Col = 1 While Col <= rs.Fields.Count ss.ActiveSheet.Cells(Row, Col).Value = rs.Fields(Col - 1).Value Col = Col Wend Row = Row rs.MoveNext Wend Assumes open RecordSet Check for null Inside loop iterates across columns of rs, inserting values in spreadsheet cells Outer loop walks down through rows Column headers from .Name Recall we did not have to do this with ole db and data bound grid control No null values

48 Populate Faster Set field = rs.Fields Set cell = ss.ActiveSheet.Cells Row = 1 While Not rs.EOF Col = 1 While Col <= rs.Fields.Count cell(Row, Col).Value = field(Col - 1).Name Col = Col Wend Row = Row rs.MoveNext Wend Indexes vs. subscripts in Cobol

49 OWC Chart General purpose charting functions
45 chart types ChartSpace - one or more charts Careful with terminology Series – points to be plotted as a group Value axis is vertical (y) Category axis is horizontal (x) Value axis scales nicely Category axis scaling is weak personally challenged by chart terminology, but then sas/graph gave me fits too Value scales nicely, category requires effort Series must be homogenous, Ive run afoul of this If you are comfortable with the construction of charts in excel…

50 Chart Types Column Bar Line Pie Scatter Bubble Area Doughnut Radar Stock Polar Clustered Stacked Stacked100 Markers Smooth Exploded Filled HLC OHLC Combo 45 defined

51 OWC Chart API Set cs.DataSource = ss.Object Chart data will come from spreadsheet Set chart = cs.Charts.Add() Add a chart to the chart space cs.Clear Clear all charts in the chart space Set c = cs.Constants Constants available at run-time Chart can be linked to different data sources, at the same time ADO RecordSet Array in memory

52 OWC Chart - Formatting chart.Type = c.chChartTypeLine Basic chart type – 46 varieties chart.HasLegend = True Chart will have legend chart.HasTitle = True Chart will have title chart.Title.Caption = “C1” Take title from cell C1 in spreadsheet

53 OWC Chart - SetData Method used to identify series 1) Dimension or attribute of chart 2) Data source 3) Data Reference chart.SetData c.chDimSeriesNames, 0, “A2“ Variable name that will appear in legend chart.SetData c.chDimValues, 0, “C2:C4“ Cells containing value (y) axis data points chart.SetData c.chDimCategories, 0, “B2:B4” Cells with category (x) axis data points Define a series

54 OWC Chart Series

55 OWC Chart Series A B C 1 Process StarTime PctCpuTm 2 InetInfo 01:00 30
02:00 20 4 03:00 25

56 Chart from Spreadsheet
set cs.DataSource = ss.Object Set chart = cs.Charts.Add() Set c = cs.Constants chart.Type = c. chChartTypeColumnClustered chart.HasLegend = True chart.SetData c.chDimSeriesNames, 0, “A2“ chart.SetData c.chDimValues, 0, “C2:C4“ chart.SetData c.chDimCategories, 0, “B2:B4"

57 References Programming Microsoft Office 2000 Web Components
By Dave Stearns Microsoft Press Personally, not the best reference for beginners

58 References SAS ODBC User’s Guide and Programmer’s Reference, SAS Institute Microsoft Developer Network Library (MSDN) Microsoft TechNet newsgroups Public.Data.ADO.RDS Public.Office.Developer.Web.Components Carl Prothman

59 SasToOwc.htm – Sample App

60 Issues Much of this is Windows-only technolgy
Un-terminated character strings when accessing SAS ODBC data sources through RDS Netscape Navigator 4.5 does not natively support COM controls

61 Summary i'm not going to stand here and tell you this was all a piece of cake. It took me a long to\ime to get this all to work - and that's precicely why I decided to write it up. It is frought with all the problems you would expect when learning what mey be new languages, developement environments, and/or architecutres. Hopefully the descriptions, explanations, and code snippets and downloads will allow you to get something up and running without much effort and give you enough understanding to be able to taylor it to your needs C GChart Lots of other ways to to this – Discussed here this year (Arron on Thursday) and in the past Complexity – no harder than learning how to do the Data step coding and Proc Gchart Only scratched the surface … power and flexibility of these power

Download ppt "Publishing Your PDB Under Windows"

Similar presentations

Ads by Google