moving from access databases to a visual studio/sql server solutions andrew couch uk access user...
TRANSCRIPT
![Page 1: Moving from Access Databases to a Visual Studio/SQL Server Solutions Andrew Couch UK Access User Group asc associates](https://reader035.vdocuments.site/reader035/viewer/2022070306/5518a194550346991f8b48d8/html5/thumbnails/1.jpg)
Moving from Access Databases to a Visual Studio/SQL Server Solutions
Andrew CouchUK Access User Group
asc associateswww.upsizing.co.uk
![Page 2: Moving from Access Databases to a Visual Studio/SQL Server Solutions Andrew Couch UK Access User Group asc associates](https://reader035.vdocuments.site/reader035/viewer/2022070306/5518a194550346991f8b48d8/html5/thumbnails/2.jpg)
Phases
Migrating the database design and data to SQL Server, re-linking Access application to SQL Server
Migrating queries to views and stored procedures, also re-packaging the SQL behind Forms and Reports to SQL Server if targeting to Visual Studio. Performance tuning or to make the next step.
Migrating the application to use web forms and report services with Visual Studio
![Page 3: Moving from Access Databases to a Visual Studio/SQL Server Solutions Andrew Couch UK Access User Group asc associates](https://reader035.vdocuments.site/reader035/viewer/2022070306/5518a194550346991f8b48d8/html5/thumbnails/3.jpg)
Migrating the Database Design and Data
![Page 4: Moving from Access Databases to a Visual Studio/SQL Server Solutions Andrew Couch UK Access User Group asc associates](https://reader035.vdocuments.site/reader035/viewer/2022070306/5518a194550346991f8b48d8/html5/thumbnails/4.jpg)
Preparing the Database Design
Access Design• Tables & Fields
• Add missing defaults for Boolean fields
• Avoid zero-length string anomaly
• Add timestamps (recommended)
• Add auditing fields (nice opportunity to add at this point)
• Decide on specific data type mappings; memos to VARCHAR(MAX) or TEXT, OLE Objects to VARBINARY(MAX) or IMAGE and setting decimals precision
• Relationships• Correct for cycles removing cascade operations from
relationships (www.upsizing.co.uk/Art6_Relationships.aspx)
![Page 5: Moving from Access Databases to a Visual Studio/SQL Server Solutions Andrew Couch UK Access User Group asc associates](https://reader035.vdocuments.site/reader035/viewer/2022070306/5518a194550346991f8b48d8/html5/thumbnails/5.jpg)
Preparing the Database Design (2)
• Table validation rules (checks)• Translate Access expressions and functions
• Field validation rules (checks)• Translate Access expressions and functions
• Indexes• Reject inefficiencies, 20% rule• Check indexing on foreign key fields• Check for primary keys, add if absent• Map ‘unique indexes that ignore nulls’ to unique index
and trigger
![Page 6: Moving from Access Databases to a Visual Studio/SQL Server Solutions Andrew Couch UK Access User Group asc associates](https://reader035.vdocuments.site/reader035/viewer/2022070306/5518a194550346991f8b48d8/html5/thumbnails/6.jpg)
Schema’s and Synonyms
![Page 7: Moving from Access Databases to a Visual Studio/SQL Server Solutions Andrew Couch UK Access User Group asc associates](https://reader035.vdocuments.site/reader035/viewer/2022070306/5518a194550346991f8b48d8/html5/thumbnails/7.jpg)
Architecture : Schemas/Security
Schemas• Group together design objects
• Partioning designs
• Combining Access databases
• Synonyms required for ease of reference
Security• Database roles
• Grant permission on schemas
• Assign users to roles
• User database roles schemas
![Page 8: Moving from Access Databases to a Visual Studio/SQL Server Solutions Andrew Couch UK Access User Group asc associates](https://reader035.vdocuments.site/reader035/viewer/2022070306/5518a194550346991f8b48d8/html5/thumbnails/8.jpg)
Preparing Data
Issues• Missing data in a required field, fix data or make field allow
nulls, no workaround beyond this• Violation of other checks (validation rules), avoid by adding
checks after data migrated, or fix the data, adding checks after migration gets around some of these issues
• Date range problem and invalid dates, fix the data, no work around
• Violation of R.I and deep seated corruption, difficult to generalise, migrate data, remove bad data then add relationships
![Page 9: Moving from Access Databases to a Visual Studio/SQL Server Solutions Andrew Couch UK Access User Group asc associates](https://reader035.vdocuments.site/reader035/viewer/2022070306/5518a194550346991f8b48d8/html5/thumbnails/9.jpg)
Migration Sequence
Initial Migration• Migrate optimised and corrected structure
• Check and fix data
• Migrate data
• Add checks, triggers, indexing and relationships
Commissioning• Check and fix data
• Drop checks, triggers, indexing and relationships
• Empty data
• Migrate data
• Add checks, triggers, indexing and relationships
![Page 10: Moving from Access Databases to a Visual Studio/SQL Server Solutions Andrew Couch UK Access User Group asc associates](https://reader035.vdocuments.site/reader035/viewer/2022070306/5518a194550346991f8b48d8/html5/thumbnails/10.jpg)
Skills : SQL Server a new world ?
A more important system ?• Dba’s, support, security and reviews of changes to
design• Production and development environments• More developers
Better control• Version Control• Comparing Development and Production• Script files to transfer change, GUI dangers in
production environments!
![Page 11: Moving from Access Databases to a Visual Studio/SQL Server Solutions Andrew Couch UK Access User Group asc associates](https://reader035.vdocuments.site/reader035/viewer/2022070306/5518a194550346991f8b48d8/html5/thumbnails/11.jpg)
Skills : SQL Server a new world ? (2)
Other Issues• Backups• Server Tuning• Security
Access Application• Could stop here and retain the Access front-end• Tune SQL converting as required to SP’s, Views and
Pass Through• Or we can go on and do further bulk conversions• Do all your existing queries work? Do you need all your
existing queries ?
![Page 12: Moving from Access Databases to a Visual Studio/SQL Server Solutions Andrew Couch UK Access User Group asc associates](https://reader035.vdocuments.site/reader035/viewer/2022070306/5518a194550346991f8b48d8/html5/thumbnails/12.jpg)
Migrating queries and re-packaging the SQL behind Forms and Reports
![Page 13: Moving from Access Databases to a Visual Studio/SQL Server Solutions Andrew Couch UK Access User Group asc associates](https://reader035.vdocuments.site/reader035/viewer/2022070306/5518a194550346991f8b48d8/html5/thumbnails/13.jpg)
Screen Control Example
SELECT BigCustomers.Country, BigCustomers.*FROM BigCustomersWHERE (((BigCustomers.Country)=[Forms]![frmPrompt]![txtCountry]));
![Page 14: Moving from Access Databases to a Visual Studio/SQL Server Solutions Andrew Couch UK Access User Group asc associates](https://reader035.vdocuments.site/reader035/viewer/2022070306/5518a194550346991f8b48d8/html5/thumbnails/14.jpg)
Parameter Table & View
CREATE TABLE tblParameters(SelectedCountry VARCHAR(15),SelectedDate DATETIME,SelectedRegion VARCHAR(15),UserName VARCHAR(128) DEFAULT suser_name())
CREATE VIEW vw_tblParametersASSELECT * FROM tblParametersWHERE UserName = suser_name()
![Page 15: Moving from Access Databases to a Visual Studio/SQL Server Solutions Andrew Couch UK Access User Group asc associates](https://reader035.vdocuments.site/reader035/viewer/2022070306/5518a194550346991f8b48d8/html5/thumbnails/15.jpg)
Translated View
CREATE VIEW vw_ResultsSimpleASSELECT * FROM BigCustomersCROSS JOIN vw_tblParametersWHERE [Country] = [SelectedCountry]
SELECT BigCustomers.Country, BigCustomers.*FROM BigCustomersWHERE (((BigCustomers.Country)=[Forms]![frmPrompt]![txtCountry]));
![Page 16: Moving from Access Databases to a Visual Studio/SQL Server Solutions Andrew Couch UK Access User Group asc associates](https://reader035.vdocuments.site/reader035/viewer/2022070306/5518a194550346991f8b48d8/html5/thumbnails/16.jpg)
Another Example; optional start
SELECT IIf(Not IsNull([Forms]![frmPrompt]![txtTheDate]),IIf([Forms]![frmPrompt]![txtTheDate]<[Date],1,0),1) AS Expr1, IIf(Not IsNull([Forms]![frmPrompt]![txtCountry]),IIf([Forms]![frmPrompt]![txtCountry]=[Country],1,0),1) AS Expr2, BigCustomers.*FROM BigCustomersWHERE (((IIf(Not IsNull([Forms]![frmPrompt]![txtTheDate]),IIf([Forms]![frmPrompt]![txtTheDate]<[Date],1,0),1))=1) AND ((IIf(Not IsNull([Forms]![frmPrompt]![txtCountry]),IIf([Forms]![frmPrompt]![txtCountry]=[Country],1,0),1))=1));
![Page 17: Moving from Access Databases to a Visual Studio/SQL Server Solutions Andrew Couch UK Access User Group asc associates](https://reader035.vdocuments.site/reader035/viewer/2022070306/5518a194550346991f8b48d8/html5/thumbnails/17.jpg)
Making Parameters Optional
CREATE VIEW vw_ResultsASSELECT * FROM BigCustomersCROSS JOIN vw_tblParametersWHERE COALESCE ([Country], ' ') =
COALESCE ([SelectedCountry], [Country], ' ') AND COALESCE ([Date], ' 1/1/1900') >=
COALESCE ([SelectedDate], [Date], '1/1/1900')
![Page 18: Moving from Access Databases to a Visual Studio/SQL Server Solutions Andrew Couch UK Access User Group asc associates](https://reader035.vdocuments.site/reader035/viewer/2022070306/5518a194550346991f8b48d8/html5/thumbnails/18.jpg)
Translating SQL
“We choose here to consider maximising translation of objects to SQL Server objects,
rather than embedding SQL in code”
Stored Procedures Views Access Support Library Custom UDF Translation Parameter Translation Form/Report Control and Record Source re-packaging
SQL
![Page 19: Moving from Access Databases to a Visual Studio/SQL Server Solutions Andrew Couch UK Access User Group asc associates](https://reader035.vdocuments.site/reader035/viewer/2022070306/5518a194550346991f8b48d8/html5/thumbnails/19.jpg)
![Page 20: Moving from Access Databases to a Visual Studio/SQL Server Solutions Andrew Couch UK Access User Group asc associates](https://reader035.vdocuments.site/reader035/viewer/2022070306/5518a194550346991f8b48d8/html5/thumbnails/20.jpg)
INSERT, UPDATE, DELETE• Stored Procedure (need to use pass-through queries to call
these by name)
• Pass-Through Query; containing explicit SQL
SELECT, CROSSTAB• View (need to indicate unique fields to make these
updateable, where possible, can be linked just like tables)
• Stored Procedure (read-only, can not be linked need to use pass-through queries to call these)
• Pass-Through Query (read-only); containing explicit SQL
What Queries Translate To
![Page 21: Moving from Access Databases to a Visual Studio/SQL Server Solutions Andrew Couch UK Access User Group asc associates](https://reader035.vdocuments.site/reader035/viewer/2022070306/5518a194550346991f8b48d8/html5/thumbnails/21.jpg)
References Nested Queries (Calculations)
• Work out how many layers are going to be required, and then decide whether it would be better to generate a results table using selection criteria, upon which to base the calculations or work with the Nested Query.
• www.upsizing.co.uk/Art3_NestedQueries.aspx
Parameters Table (Parameters)• Isolate all the screen references and parameter statements
and use a table containing parameters to filter the SQL, Conversion of IIF statements to CASE statements and use of COALESCE functions for optional parameters.
• www.upsizing.co.uk/Art7_Controls.aspx
![Page 22: Moving from Access Databases to a Visual Studio/SQL Server Solutions Andrew Couch UK Access User Group asc associates](https://reader035.vdocuments.site/reader035/viewer/2022070306/5518a194550346991f8b48d8/html5/thumbnails/22.jpg)
Migrating the Application
![Page 23: Moving from Access Databases to a Visual Studio/SQL Server Solutions Andrew Couch UK Access User Group asc associates](https://reader035.vdocuments.site/reader035/viewer/2022070306/5518a194550346991f8b48d8/html5/thumbnails/23.jpg)
Access Application Objects
Menus, Toolbars and Navigation
Forms
Reports
Macros, Modules and Form/Report Module Code
![Page 24: Moving from Access Databases to a Visual Studio/SQL Server Solutions Andrew Couch UK Access User Group asc associates](https://reader035.vdocuments.site/reader035/viewer/2022070306/5518a194550346991f8b48d8/html5/thumbnails/24.jpg)
Architecture : Web Forms a Strategy Simple bound controls and templates
Web site menu
Master Pages and style sheets
Further points to consider• Screen layouts and screen areas
• Searching and filtering data
![Page 25: Moving from Access Databases to a Visual Studio/SQL Server Solutions Andrew Couch UK Access User Group asc associates](https://reader035.vdocuments.site/reader035/viewer/2022070306/5518a194550346991f8b48d8/html5/thumbnails/25.jpg)
Example Converted Form
![Page 26: Moving from Access Databases to a Visual Studio/SQL Server Solutions Andrew Couch UK Access User Group asc associates](https://reader035.vdocuments.site/reader035/viewer/2022070306/5518a194550346991f8b48d8/html5/thumbnails/26.jpg)
Sitemap
![Page 27: Moving from Access Databases to a Visual Studio/SQL Server Solutions Andrew Couch UK Access User Group asc associates](https://reader035.vdocuments.site/reader035/viewer/2022070306/5518a194550346991f8b48d8/html5/thumbnails/27.jpg)
Master pages and Content Areas
![Page 28: Moving from Access Databases to a Visual Studio/SQL Server Solutions Andrew Couch UK Access User Group asc associates](https://reader035.vdocuments.site/reader035/viewer/2022070306/5518a194550346991f8b48d8/html5/thumbnails/28.jpg)
CSS to Control Presentation
![Page 29: Moving from Access Databases to a Visual Studio/SQL Server Solutions Andrew Couch UK Access User Group asc associates](https://reader035.vdocuments.site/reader035/viewer/2022070306/5518a194550346991f8b48d8/html5/thumbnails/29.jpg)
Searching and Filtering
![Page 30: Moving from Access Databases to a Visual Studio/SQL Server Solutions Andrew Couch UK Access User Group asc associates](https://reader035.vdocuments.site/reader035/viewer/2022070306/5518a194550346991f8b48d8/html5/thumbnails/30.jpg)
Application Issues
“We are only considering the use of bound controls with custom templates here”
Inconsistent data in fields
• invalid drop-down box selections
• invalid radio button selections
Error handling
• error handling is a necessity
![Page 31: Moving from Access Databases to a Visual Studio/SQL Server Solutions Andrew Couch UK Access User Group asc associates](https://reader035.vdocuments.site/reader035/viewer/2022070306/5518a194550346991f8b48d8/html5/thumbnails/31.jpg)
Application Issues (2)
Grid control when inserting data
Searching and filtering for data
Locking problems• No support for timestamps on bound controls
Security strategies• Internet• Integrated security• ASP. net security
![Page 32: Moving from Access Databases to a Visual Studio/SQL Server Solutions Andrew Couch UK Access User Group asc associates](https://reader035.vdocuments.site/reader035/viewer/2022070306/5518a194550346991f8b48d8/html5/thumbnails/32.jpg)
Report Services
Easy security with groups
Forms to prompt
Launching using ReportViewer controls
Import Access reports into a Visual Studio Report Server project
![Page 33: Moving from Access Databases to a Visual Studio/SQL Server Solutions Andrew Couch UK Access User Group asc associates](https://reader035.vdocuments.site/reader035/viewer/2022070306/5518a194550346991f8b48d8/html5/thumbnails/33.jpg)
Report Server
![Page 34: Moving from Access Databases to a Visual Studio/SQL Server Solutions Andrew Couch UK Access User Group asc associates](https://reader035.vdocuments.site/reader035/viewer/2022070306/5518a194550346991f8b48d8/html5/thumbnails/34.jpg)
Skills : Lost Count Now?
New technology areas• SQL Server• Visual Studio web forms and .net• Report Server• IIS
Challenges for newcomers• Security• Security• And security
![Page 35: Moving from Access Databases to a Visual Studio/SQL Server Solutions Andrew Couch UK Access User Group asc associates](https://reader035.vdocuments.site/reader035/viewer/2022070306/5518a194550346991f8b48d8/html5/thumbnails/35.jpg)
MUST
Download a trial version from www.upsizing.co.uk
Site contains a number of technical articles, expanding on these topics