Tải bản đầy đủ - 0 (trang)
Hack 56. Distribute a Split Database with Predefined Table Links

Hack 56. Distribute a Split Database with Predefined Table Links

Tải bản đầy đủ - 0trang

deleteeverythingbutthetables.

UsetheDatabaseSplitterutility(Tools Database

Utilities).ThisautomaticallycreatesanAccessfilewithjust

thetablesand,atthesametime,removesthetablesfrom

thedatabaserunningtheutility.

Thentheback-enddatabase(theonewiththetables)goesona

networkshare,whilethefront-enddatabaseisdistributedto

usersandisrunfromtheirPCs.Theproblemisthatthefrontenddatabasemustbelinkedtothetablesintheback-end

database.SimulatingtheselinksonyourdevelopmentPC

beforedistributingthefrontendisthepointhere.Ifyoucanset

thelinkssothattheyarethesameasthoseintheproduction

environment,userswillnothavetodealwithestablishingthe

linksthemselvesfromtheirPCs.

Inotherwords,youcandistributethefrontendprelinked.Allof

thisisbasedontheassumptionthatadrive-mappingstandard

isinplaceandthatalluserswillhaveanidenticalmappath.



6.3.1.CopyingtheNetworkDrivetoYour

DevelopmentMachine

TheSUBSTDOScommandisallyouneedtocopythenetwork

drivetoyourdevelopmentmachine.Onyourdevelopment

machine,youcanuseSUBSTtocreateamapthatmatchesthe

oneusersneed.

First,createadirectoryonyourcomputerthatmatchesthe

folderonthesharewheretheback-enddatabasewillgo.Ifthe

networkpathincludessubdirectories,createapaththat

matchesthatpathstructureonyourdevelopmentmachine.

ThesyntaxforusingSUBSTrequiresthenewdriveletterandthe



pathitissetto,likethis:





SUBST


Forexample,ifyouhaveasubfoldernamedXYZ_Corpinyour

C:\Clientsfolder,andyouwanttomapthatfoldertoanS:\

drive,clickStart/Run;typecommand(Windows98,Me)orCMD

(WindowsNT,2000,XP);clickOK;andenterthisatthe

commandline:





SUBSTS:C:\Clients\XYZ_Corp



Figure6-1showshowyoudothisintheCommandPromptbox.



Figure6-1.UsingSUBST



IfusersareaccessingasubfolderundertheS:drive,create

matchingfoldernamesunderthefolderthatwassubstitutedto

theS:drive.Placetheback-enddatabaseintheappropriate

folder.

Now,whenyouareinthefront-enddatabasefileandare

linkingtheback-endtables,browsetoyournewS:drivetofind

theback-enddatabase,therebykeepingthelinksthesameas



whattheusersneed.Whenyousendyourusersanupdate,

theyshouldnothavetorelinkanything.Thisnewdriveletter

willevenshowupwhenyouopenMyComputer.Thenewvirtual

driveletterwilllastuntilthenexttimeyourestart.Ifyoudecide

younolongerneedavirtualdrive,youcangetridofitwiththe

/dswitch:





SUBSTS:/d



It'simportanttonotethatthisremovesthevirtualmapping;it

doesn'tdeletethefolderoritsfiles.Also,youcan'tuseSUBSTif

youalreadyhaveadriveusingthatletter,soifyourkeychain

flashdriveisusingG:\,youhavetosafelyremoveitbefore

SUBSTingafoldertousetheG:drive.

Ofcourse,thistechniqueworksonlyinextremelystable

environments,whereallusershavethesamedriveletter

mappedtothegivenshare.AlthoughS:mightworkforyour

primarycontact,otherusersoftheapplicationmighthavea

differentlettermappedtothatlocation,ortheymightnothave

anylettermapped.Theycouldbeaccessingthefolderthrough

itsUniversalNamingConvention(UNC)name

(\\ServerName\ShareName).Ifthisisthecase,youcan

emulatethisonyourPCaswellaslongasyouarewillingto

renameyourPCtomatchtheserver'sname(youcanalways

changeitbacklater).



6.3.2.UsingUNCInstead

IfyouwanttouseUNCinstead,youneedtorenameyour

computer.First,youneedtoknowtheservernameattheclient

siteandthefullpathoffoldersandsubfolderstothesharethat

willholdyourback-enddatafile.Torenameyourcomputerto

matchtheserver,bringupyourPC'sSystemPropertiesby



right-clickingMyComputerandclickingProperties,orby

double-clickingtheSystemiconintheControlPaneltoopenthe

SystemPropertiesdialogbox.SelecttheComputerNametab,

andthenclicktheChangebutton.WhenyouseetheComputer

NameChangesdialogbox,showninFigure6-2,typethe

desirednameforthecomputer.Itwillrequireareboottotake

effect.Ofcourse,thisassumesyouwillbecreatinganame

conflictonthenetwork.Theassumptionisthatyour

developmentmachineisn'tontheproductionnetwork.Ifitis,

youcandisconnectyourcomputerduringthisprocess.



Figure6-2.Changingthenameofthecomputer



So,ifXYZCorp.'sserver,calledServerName,hasaDeptShare

folderandasubfoldercalledDataFolderthatwillholdyour

datafile,changeyourcomputer'snametoServerName.Then,

createafoldernamedDeptShareofftherootofyourC:drive,

andcreateasubfoldercalledDataFolderinsidetheDeptShare

folder.

Oncethefolderstructureisinplace,browsetotheDeptShare

folder,rightclickinanemptyareaofthefolder,andthenclick

Properties.SelecttheSharingtab,andmakeselectionstoshare

thefolder,asshowninFigure6-3.



Figure6-3.Sharingafolder



NowgotoMyNetworkPlaces,andclickAddaNetworkPlace.

ClickNextonthewizard'sfirstscreen,andthewizardwillask

youwheretocreatethenewnetworkplace;select"Choose

anothernetworklocation."ClickNext,andintheInternetor

NetworkAddressbox,type\\ServerName\DeptShare.ClickNext;

Windowswillaskwhattocalltheshare.Ifthenameisn't

alreadyinthebox,typeDeptShareforServerName.ClickOK,and

thenclickFinish.

Finally,backinyourAccessapplicationfile,deleteallthelinked



tables.Thistime,whenrelinkingthetables,makesuretogo

throughMyNetworkPlaces/EntireNetworkinthelinkdialogto

browsetothedatafile,ortype\\servername\deptshareintothe

dialogtobrowsetothedatafile.ThiscausesAccesstocreate

thelinkstousetheUNCnamingconvention.IfyouusetheMy

Computershortcuttoyourshare,Accessrecognizesthatitis

localandusestheC:drivepathtocreatethelink.Toensure

thatyourlinkisusingUNC,typethisinthedebugwindow:





?Currentdb.TableDefs("").Connect



Makesuretoputthenameofoneofthelinkedtablesinthe

codelinewhereyouseetheprompt.The

responseshouldlooklikethis:





;DATABASE=\\Servername\DeptShare\DataFolder\Project_dat



Notethatyouwillseethenameofyourdatabase;youwon't

seeProject_dat.mdb.Ifyougetthefollowingresponse,youneed

totryagain,makingsureyougothroughtheentirenetwork,

workgroup,computername,andsharenamewhenbrowsingto

yourdatafile:





;DATABASE=C:\DeptShare\DataFolder\Project_dat.mdb



Oncethisiscorrect,endusersattheclientsiteshouldn'tneed

torelink,regardlessofwhichdriveletter(ifany)theyhave

mappedtothenetworklocation.

SteveConklin



Hack57.BuildaTime-OutFeature



Makesureyourdataissavedandavailabletoothers.

Locktherecordswhenthey'renotbeingupdated.

Thephonerings,oryouarelatetoameeting,oranynumberof

otherdistractionspopup.Ithappenstoallofus.Unfortunately,

yousometimesforgettocloseoutofthefileopenonyourPC.

Inamultiuserdatabase,thiscanbearealnuisance.Depending

ontherecord-lockingschemebeingused,ifarecordisleftin

themiddleofanedit,otherworkersmightnotbeabletomake

changestothatrecord.Figure6-4showsthedreadfulmessage

ausercangetwhenattemptingtomakeachangetoarecord

someoneelsehasleftopen.



Figure6-4.Arecordthathasbeenleftinan

editedstate



AlthoughthemessageinFigure6-4givestheseconduserthe

optionsheneeds,itisbettertonotevenseethismessage,ifit



canbeavoided.Aproductivemeasureforthissituationisto

closeaforminwhichnoactivityissensedafteraperiodof

time.Inotherwords,ifthefirstuserhasnotcompletedany

changestotherecordwithinaspecifiedtime,theformshould

justclose.Closingtheformendstherecord-editingprocess,

andthechangesaresavedautomatically.Thealternative,to

dropthechanges,isdiscussedattheendofthishack.



6.4.1.It'sAboutTime

FormshaveanintrinsictimercontrolandTimerevent.Ifyou're

familiarwithVisualBasic,youknowhowtoactuallyplacea

timercontrolonaform.InAccess,thecontroliseffectively

alreadyontheform,althoughyoudon'tseeit.Instead,youuse

thepropertysheettosettheIntervalpropertyandtoindicate

whatoccursintheOnTimerevent.

Todisplaythepropertysheet,opentheforminDesignmode,

andpressF4onthekeyboard.Ifnecessary,makesurethe

propertysheetisdisplayingpropertiesabouttheformitself,not

aboutoneofthecontrolsorsections.SelectFormfromthe

drop-downboxatthetopofthepropertysheet.

Figure6-5showsthepropertysheetsettodisplaythe

propertiesfortheform.TheOnTimerandTimerIntervalproperties

arefoundonboththeEventtabandtheAlltab.



Youcandisplaythepropertysheetinafewways.YoucanpressF4,or

youcanpressAlt-Enter.YoucanalsousetheView

Properties

menu,orjustclickthePropertiesbuttonontheFormDesigntoolbar.



TheIntervalpropertyacceptsvaluesbetween0and2,147,483,647



Tài liệu bạn tìm kiếm đã sẵn sàng tải về

Hack 56. Distribute a Split Database with Predefined Table Links

Tải bản đầy đủ ngay(0 tr)

×