Date post: | 03-Jun-2018 |
Category: |
Documents |
Upload: | pavan-krishna-o |
View: | 232 times |
Download: | 0 times |
of 22
8/12/2019 Microsoft Client Virtualization Strategy White Pape
1/22
8/12/2019 Microsoft Client Virtualization Strategy White Pape
2/22
Data Provider
? Provides and "aintains lin5 to database
+ight#eight
)et of related co"ponents
o /onnection
? actual connection to D6
.NET provides t#o providers ! ),+ )erver and O+E D6
? ),+ )erver "uch lighter than O+E D6
? 7nfo re$uired for connection stored in /onnection)tring
propert
? )i"ilar to previous O+E D6 version
Onl set #hen connection closed
ust al#as specif server %can be set to local&
)ecurit info %e.g. pass#ord& not returned unless 8Persist )ecurit 7nfo = true9 present
Argu"ent E4ception generated if /onnection)tring cannot be parsed
Dont need to specif provider %e.g. ),+O+ED6& if using )$l/onnection
Avoid using ;D+ %;niversal Data +in5& files as parsed ever ti"e connection opened
%because file "a have changed& ! use static connection string? Auto"aticall pooled
? sste" #ill reuse e4isting connection if
/onnection)tring "atches and not currentl in use %i.e.
/lose%& or Dispose%& has been called&
connection re"oved if lifeti"e e4pired or connection severed
? 'aises ( events related to connection state
? 7nfoessage !
8/12/2019 Microsoft Client Virtualization Strategy White Pape
3/22
o /o""and
? E4ecute D6 co""ands across /onnection
.NET provides t#o providers ! ),+ )erver and O+E D6
/onstructor ta5es optional args
? ),+ state"ent to e4ecute at data source
/onnection ob2ectTransaction ob2ect
? E4ecuteNon,uer ! e4ecute co""ands #ith no return values*
e.g. Data Definition +anguage DD+ state"ents li5e /'EATE
TA6+E and so"e )Ps
E4ecute)calar ! e4ecute co""ands returning single value %value of first colu"n of
first ro# in result set&
E4ecute'eader ! retrieve result as strea" of data via Data'eader ob2ect
properties represent database co""ands
? )elect/o""and ! contains co""and te4t or ob2ect to
select data fro" db. E4ecuted #hen Fill "ethod called.
7nsertco""and ! contains co""and te4t or ob2ect to insert data into table.
Delete/o""and ! contains co""and te4t or ob2ect to delete ro# fro" table.
;pdate/o""and ! contains co""and te4t or ob2ect to update data in db.
Use subject to ourTer"s and /onditions Written By 'oss Fruen
http://www.gsys.biz/Documents/Downloads/MCP/70-316http://www.gsys.biz/Documents/Downloads/MCP/70-316http://www.gsys.biz/homepages/rfruen/http://www.gsys.biz/homepages/rfruen/http://www.gsys.biz/Documents/Downloads/MCP/70-3168/12/2019 Microsoft Client Virtualization Strategy White Pape
4/22
DataReader Vs DataSet
? ;se Data)et for follo#ing
o 'e"ote data bet#een tiers or fro" -+
8/12/2019 Microsoft Client Virtualization Strategy White Pape
5/22
myConnection.ConnectionString =Provider=Microsoft.Jet.O!D".#.$;D%t%So&rce=C'ort*wind.mdb+;
Using Command? Do not re$uire DataAdapter to interact #ith D6
/reate:
o Drag stored procedure fro" )erver E4plorer to designer
Drag )$l/o""and OleDb/o""and fro" data tab or toolbo4
Declare and instantiate instance of /o""and ob2ect
? /o""andTpe propert indicates its tpe
o Te4t ! /o""andTe4t contains ),+ $uer
)toredProcedure ! /o""andTe4t contains na"e of )P
TableDirect ! na"e of table%s& indicated b /o""andTe4t. 'eturns all colu"ns and
ro#s of specified tables
? )et /onnection propert to active connection
Para"eters are values that fill placeholders in co""and te4t at run ti"e* stored in
Para"eters propert and read at runti"e
S,lConnection nwindConn = new S,lConnection(-D%t%So&rce=loc%l*ost;ntegr%ted Sec&rity=SSP;niti%lC%t%log=nort*wind-);
S,lComm%nd s%lesCMD = new S,lComm%nd(-S%les"yC%tegory-/ nwindConn);s%lesCMD.Comm%nd0y1e = Comm%nd0y1e.StoredProced&re;
S,lP%r%meter myP%rm = s%lesCMD.P%r%meters.2dd(-3C%tegory%me-/S,lDb0y1e.4%rC*%r/ 56);myP%rm.4%l&e = -"ever%ges-;
nwindConn.O1en();
S,lD%t%7e%der my7e%der = s%lesCMD.!8ec&te7e%der();
Console.9riteine(-:$/ :5-/ my7e%der.
8/12/2019 Microsoft Client Virtualization Strategy White Pape
6/22
Para"eterNa"e ! na"e to be used as 5e in code %if not using ordinal&
Precision ! "a4i"u" nu"ber of digits in value %nu"eric and deci"al&
)cale ! nu"ber of deci"al places in value %nu"eric and deci"al&
)ie ! "a4i"u" sie of data in colu"n %string and binar&
)ource/olu"n ! colu"n to loo5 up or "ap values
)ourceBersion ! version of colu"n to use #hen editingBalue ! Balue represented b para"eter
? /an provide /o""and6ehavior argu"ent to e4tract 6+O6s fro" database.
)et to /o""and6ehavior.)e$uentialAccess and use Cet6tes%& to access data.
ust retrieve data in order presented ! once reader steps beond that colu"n
it is no longer available
S,lConnection 1&bsConn = new S,lConnection(-D%t%So&rce=loc%l*ost;ntegr%ted Sec&rity=SSP;niti%l C%t%log=1&bs;-);S,lComm%nd logoCMD = new S,lComm%nd(-S!!C0 1&b>id/ logo ?7OM1&b>info-/ 1&bsConn);
?ileStre%m fs; @@ 9rites t*e "O" to % file@@ (A.bm1).
"in%ry9riter bw; @@ Stre%ms t*e "O" to t*e?ileStre%m obBect.
int b&fferSie = 5$$; @@ Sie of t*e "O" b&ffer.byteE o&tbyte = new byteb&fferSieE; @@ 0*e "O" byteE b&ffer to
@@ be filled by id = --; @@ 0*e 1&blis*er id to &se in@@ t*e file n%me.
@@ O1en t*e connection %nd re%d d%t% into t*e D%t%7e%der.1&bsConn.O1en();S,lD%t%7e%der my7e%der =logoCMD.!8ec&te7e%der(Comm%nd"e*%vior.Se,&enti%l2ccess);
w*ile (my7e%der.7e%d()):
@@ id = my7e%der.id F -.bm1-/ ?ileMode.O1enOrCre%te/?ile2ccess.9rite);
bw = new "in%ry9riter(fs);
@@ 7eset t*e st%rting byte for t*e new "O".
st%rtnde8 = $;
Use subject to ourTer"s and /onditions Written By 'oss Fruen
http://www.gsys.biz/Documents/Downloads/MCP/70-316http://www.gsys.biz/Documents/Downloads/MCP/70-316http://www.gsys.biz/homepages/rfruen/http://www.gsys.biz/homepages/rfruen/http://www.gsys.biz/Documents/Downloads/MCP/70-3168/12/2019 Microsoft Client Virtualization Strategy White Pape
7/22
8/12/2019 Microsoft Client Virtualization Strategy White Pape
8/22
o e.g. Cet6oolean%&
ust 5no# ordinal %doesnt #or5 #ith colu"n na"e&
/an retrieve ordinal fro" colu"n na"e using CetOrdinal%& "ethod
;seful if 5no# tpe of particular colu"n
? /an retrieve "ultiple result sets fro" single co""ando )et /o""andTpe of /o""and ob2ect to Te4t
)eparate ),+ state"ents using
Each ),+ state"ent e4ecuted se$uentiall* each result set returned separatel b
Data'eader
First result set returned auto"aticall fro" Data'eader
)ubse$uent result sets accessed b calling Ne4t'esult%& "ethod
do:
w*ile(my7e%der.7e%d())
:@@ oo1 t*ro&g* records of 7ecordSet
w*ile (my7e%der.e8t7es<());
? E4ecuting ad hoc ),+ $ueries
o First build co""and string
)et /o""andTe4t and /onnection properties for /o""and ob2ect at construction
string Cmd = D!!0! A ?7OM !m1loyees 9H!7!%me=I+ %String I+;
OleDbComm%nd myComm%nd = new OleDbComm%nd(Cmd/myConnection);
myConnection.O1en();myComm%nd.!8ec&teonK&ery();myConnection.Close();
? Obtain sche"a info about result using Cet)che"aTable%& "ethod. 'eturns
DataTable populated #ith sche"a for current result set. /ontains one ro# for
each colu"n in result set* each colu"n "aps to a propert of colu" returned
in result set #here /olu"nNa"e = na"e of propert and value is value of
propert
D%t%0%ble sc*em%0%ble = my7e%der.
8/12/2019 Microsoft Client Virtualization Strategy White Pape
9/22
my7owmyColE);
Console.9riteine();
? Al#as call /lose%& "ethod #hen finished #ith Data'eader
Creating Data Adapters
? +in5 data source and Data)et @ providing functionalit to retrieve data*
populate Data)et and perfor" updates
anages e4change bet#een single DataTable in Data)et and data source. Data)et
fre$uentl contains "ultiple DataTables ! create DataAdapter for each DataTable
( pri"ar adapters
o )$lDataAdapter
OleDbAdapter
? /reate DataAdpter
o 6 )erver E4plorer
? Drag table fro" Data /onnection node of )erver E4plorer to
Designer
8/12/2019 Microsoft Client Virtualization Strategy White Pape
10/22
8/12/2019 Microsoft Client Virtualization Strategy White Pape
11/22
Auto7ncre"ent)tep and Auto7ncr"ente "anuall. Fil)che"a%& is costl to
call ! if 5no# pri"ar@5e infor"ation at design ti"e then these should be set
e4plicitl to increase perfor"ance.
@@ Obt%in sc*em% vi% ?illSc*em%()
D%t%Set c&stDS = new D%t%Set();c&stD2.?illSc*em%(c&stDS/ Sc*em%0y1e.So&rce/ -C&stomers-);c&stD2.?ill(c&stDS/ -C&stomers-);
@@ Obt%in sc*em% vi% ?ill()D%t%Set c&stDS = new D%t%Set();c&stD2.MissingSc*em%2ction = MissingSc*em%2ction.2dd9it*ey;c&stD2.?ill(c&stDS/ -C&stomers-);
? Tableappings per"it use of colu"n na"es in DataTable different to those in
database* e.g. to create "apping called Authorsapping for the Authors
table use
worN2d%1ter.0%bleM%11ings.2dd(2&t*orsM%11ing+/ My2&t*ors+);
? 7f no "apping na"e is passed to Fill%& "ethod* then the DataAdapter #ill loo5
for "apping called 8Table9. 7f an colu"n is not present in "apping then it is
provided #ith default na"e of )ource/olu"nN %N being incre"ented&.
+i5e#ise if no table na"e provided then default na"e of )ourceTabeN is
used. Follo#ing creates default "apping:
D%t%0%bleM%11ing c&stM%1 = c&stD2.0%bleM%11ings.2dd(-0%ble-/-ort*windC&stomers-);
c&stM%1.Col&mnM%11ings.2dd( -Com1%ny%me-/ -Com1%ny-);
c&stM%1.Col&mnM%11ings.2dd( -Cont%ct%me-/ -Cont%ct-);c&stM%1.Col&mnM%11ings.2dd( -Post%lCode-/ -PCode-);
c&stD2.?ill(c&stDS);
? 7f )elect/o""and returns "ultiple tables* Fill #ill generate Table na"es #ith
incre"ental na"es starting fro" specified na"e. ;se table "appings to "ap
auto"aticall generated na"es to na"es #ant to use* e.g. follo#ing
)elect/o""and returns t#o tables that #ill be na"ed /usto"ers and
/usto"es3* "ap /usto"ers3 to Orders
c&stD2.0%bleM%11ings.2dd(-C&stomers5-/ -Orders-)c&stD2.?ill(c&stDS/ -C&stomers-)
Typed DataSets
? )tandard Data)et = #ee5l tped ! "ust convert data point fro" ob2ect to
desired tpe
Tped Data)et = strongl tped
7nstance of class derived fro" Data)et
/lass structure defined b -+ sche"a file %-)D& defining table na"es and tpes
Use subject to ourTer"s and /onditions Written By 'oss Fruen
http://www.gsys.biz/Documents/Downloads/MCP/70-316http://www.gsys.biz/Documents/Downloads/MCP/70-316http://www.gsys.biz/homepages/rfruen/http://www.gsys.biz/homepages/rfruen/http://www.gsys.biz/Documents/Downloads/MCP/70-3168/12/2019 Microsoft Client Virtualization Strategy White Pape
12/22
Dependence on -)D "eans onl use #here 5no# structure of data being used in
advance
/reate using Cenerate Dataset button in Data dialog bo4 ! generates -)D file and
optionall adds instance of Data)et to designer
Lesson 3
i!!ing DataSet "it#out DataAdapter
? /reate Data)et progra""aticall* and provide it #ith structure
D%t%Set myD%t%Set = new D%t%Set();
D%t%0%ble my0%ble = new D%t%0%ble();myD%t%Set.0%bles.2dd(my0%ble);
D%t%Col&mn 2cco&ntsCol&mn = newD%t%Col&mn(2cco&nts+);
myD%t%Set.0%bles$E.Col&mns.2dd(%cco&ntsCol&mn);
D%t%7ow my7ow;my7ow = myD%t%Set.0%bles$E.ew7ow();
for(int i=$; StringCollection.Co&nt; iFF):
my7ow.temco&nterE = StringCollection iE;
myD%t%Set.0%bles($).7ows.2dd(my7ow);
? Access Flat File and populate Data)et using progra""atic techni$ue outlined
above
8/12/2019 Microsoft Client Virtualization Strategy White Pape
13/22
System.O.Stre%m7e%der my7e%der = newSystem.O.Stre%m7e%der(C'?ile.t8t+);
String myString;
w*ile (my7e%der.PeeN() R= 5):
myString = my7e%der.7e%dine();myD%t%Set.0%bles0%ble 5+E.7ows.2dd
(myString.S1lit(c*%r.P%rse(/+)));
Data Re!ation O$%ects
? 'epresents relationship bet#een t#o colu"ns in different tables #ithinData)et
/ontained in 'elations propert of Data)et
/reate b specifing na"e of Data'elation* parent colu"n and child colu"n
D%t%7el%tion my7el%tion = new D%t%7el%tion(D%t%7el%tion 5+/ col&mn5/ col&mnL);
myD%t%Set.7el%tions.2dd(my7el%tion);
? ;se to retrieve parent and child ro#s b calling Cet/hild'o#s or
CetParent'o# on Data'o# providing Data'elation as par"
D%t%s7owE C*ild7ows;D%t%7ow P%rent7ow;
@@ 7et&rn %ll c*ild rows of row 5 %s defined byC&stomersOrdersC*ild7ows =myD%t%Set.0%blesC&stomers+E.7ows5E.
8/12/2019 Microsoft Client Virtualization Strategy White Pape
14/22
Foreign e ! rules used to update child ro#s #hen parent edited
? /reate ;ni$ue /onstraint
o Easiest is set ;ni$ue propert of Data'o# to true
/an create ;ni$ue/onstraint and "anuall add to /onstraints collection
Tni,&eConstr%int myConstr%int = newTni,&eConstr%int(myD%t%7ow);
myD%t%0%ble.Constr%ints.2dd(myConstr%int);
o /an specif "ultiple colu"ns
D%t%Col&mnE myCol&mns = new D%t%Col&mnLE;myCol&mns$E =
!m1loyees0%ble.Col&mns?irst%me+E;myCol&mns$E =
!m1loyees0%ble.Col&mns%st%me+E;Tni,&eConstr%int myConstr%int = new
Tni,&eConstr%int(myCol&mns);!m1loyees0%ble.Constr%ints.2dd(myConstr%int);
? /reate Foreign e /onstraint b specifing parent and child colu"ns and
adding to /onstraints collection of parent table
?oreigneyConstr%int myConstr%int = new?oreigneyConstr%int(C&stomers0bl.Col&mnsC&stomerD+E/ Orders0bl.Col&mnsC&stomerD+E);
C&stomers0bl.Constr%ints.2dd(myConstr%int);
? Foreigne/onstraint has rules e4posed as properties
o ;pdate'ule ! enforce #hen parent updated
Delete'ule ! enforce #hen parent deleted
Accept'e2ect'ule ! enforce #hen Accept/hanges "ethod of DataTable to #hich
constraint belongs is called
? )et rules to one of follo#ing values %default = /ascade&
o /ascade ! /hanges in parent cascaded to child ro#s
None ! changes in parent have no effect on child ro#s. a lead to child records
referencing invalid parents
)etDefault ! foreign 5e in child records set to its default value %see colu"ns
DefaultBalue propert&
)etNull ! foreign 5e in child table set to Null ! can result in invalid data #ithin
children
Editing Data
? Data)et "aintain ( versions of itself
o Original state
Use subject to ourTer"s and /onditions Written By 'oss Fruen
http://www.gsys.biz/Documents/Downloads/MCP/70-316http://www.gsys.biz/Documents/Downloads/MCP/70-316http://www.gsys.biz/homepages/rfruen/http://www.gsys.biz/homepages/rfruen/http://www.gsys.biz/Documents/Downloads/MCP/70-3168/12/2019 Microsoft Client Virtualization Strategy White Pape
15/22
/urrent state
?
8/12/2019 Microsoft Client Virtualization Strategy White Pape
16/22
my0r%ns%ction =myConnection."egin0r%ns%ction();
U
my0r%ns%ction.Commit();c%tc*(!8ce1tion e8)
:mytr%ns%ction.7ollb%cN();
fin%lly:
myConnection.Close();
&and!ing Update Errors
? DataAdapter provides 'o#;pdate event that fires after update event but
before e4ception thro#n ! opportunit to handle errors #ithout resource@
intensive e4ception bloc5s
'o#;pdate provides 'o#;pdatedEventArgs that is used to deter"ine error that has
occurred and ho# to proceed
o /o""and ! co""and to e4ecute #hen perfor"ing update
Errors ! errors generated b Data Provider #hen co""and e4ecutes
'ecordsAffected ! nu"ber of records affected b e4ecution of co""and
'o# ! ro# updated
)tatus @ ;pdate)tatus of co""and
? Deter"ine if error occurred b e4a"ining )tatus.
o /ontinue ! no errors have occured
ErrorsOccured ! error occurred #hile atte"pting to update this ro#
)5ipAll'e"aining'o#s ! updates for current and subse$uent ro#s should be s5ipped
)5ip/urrent'o# ! update for current ro# should be s5ipped* but rest of updates
should proceed nor"all
? /an choose to handle error in 'o#;pdated event b setting )tatus propert to
so"ething other than ErrorsOccured
o Note* if set )tatus to /ontinue the DataAdapter #ill ignore the error
and continue but unpredictable results "a arise %safer to use)5ipAll'e"aining'o#s or )5ip/urrent'o#&
7f )tatus re"ains ErrorsOccured an e4ception thro#n
private void "DataAdapterG'o#;pdated% ob2ect sender*
)ste".Data.)$l/lient.)$l'o#;pdatedEventArgs e&
H
if%e.)tatus == ;pdate)tatus.ErrorsOccured&
H
I
e.)tatus = ;pdate)tatus.)5ip/urrent'o#
Use subject to ourTer"s and /onditions Written By 'oss Fruen
http://www.gsys.biz/Documents/Downloads/MCP/70-316http://www.gsys.biz/Documents/Downloads/MCP/70-316http://www.gsys.biz/homepages/rfruen/http://www.gsys.biz/homepages/rfruen/http://www.gsys.biz/Documents/Downloads/MCP/70-3168/12/2019 Microsoft Client Virtualization Strategy White Pape
17/22
J
J
Lesson 4
Data Binding
? 'elationship bet#een data provider and consu"er
E4a"ple = Te4t6o4 #hich displas colu"n in data source at current ro#. As ro#
changes* the value displaed changes
Data Providers
? Provides data to bound properties and controls
Note ! not a DataProvider %co"ponents providing disconnected database access&
An ob2ect i"ple"enting 7+ist can be data provider %includes arras and collections&anage data currenc %i.e. current record& through /urrencanager ob2ect
Data Consumers
? /an bind an run@ti"e accessible propert of an control to a data source
T#o tpes of binding
o )i"ple ! binds one record at a ti"e to a control
/o"ple4 ! binds "ultiple records si"ultaneousl to a control* e.g. bind +ist6o4 to a
colu"n in DataTable and it #ill displa all "e"bers of that colu"n
Create Simp!e $ound contro!
? ;se Data6indings propert %instance of /ontrol6indings/ollection&
Displaed as node in Properties #indo#* e4pands to sho# properties that are
co""onl data bound
To bind propert clic5 bo4 ne4t to it in Data6indings node and select desired provider
%Data)ets and DataBie#s can be e4panded to sho# DataTables that can be e4panded
to list available colu"ns
7f propert not listed in Data6indings clic5 Advanced bo4 follo#ed b Elipses %I&
#hich lists all run ti"e available properties
? At run@ti"e can add* re"ove or clear data binding info b setting appropriate
"e"ber of Data6indings collection
6ind propert using Data6indings.Add "ethod passing in propert na"e* data source
to bind to and "e"ber of data source to bind to
0e8t"o85.D%t%"indings.2dd(0e8t+/D%t%Set5.C&stomers/ C&stomerD+);
? 7f binding to source #ithout "ultiple data "e"bers* e.g. collection or arra*
set third par" to blan5 %89&
Use subject to ourTer"s and /onditions Written By 'oss Fruen
http://www.gsys.biz/Documents/Downloads/MCP/70-316http://www.gsys.biz/Documents/Downloads/MCP/70-316http://www.gsys.biz/homepages/rfruen/http://www.gsys.biz/homepages/rfruen/http://www.gsys.biz/Documents/Downloads/MCP/70-3168/12/2019 Microsoft Client Virtualization Strategy White Pape
18/22
Data Currency
? Ever data source "anages navigation using a /urrencanager ob2ect
Data source = 3 or ( D store %DataTable* DataBie#* arra* collection&
Data)et contains "an DataTables* thus "an data sources
/urrencanager 5eeps trac5 of current record for its particular data source
For" "a have "ultiple /urrencanagers associated #ithin its data sources*"anages these through the 6inding/onte4t
/an use 6inding/onte4t to "anage position of current record for each data source
t*is."indingConte8tD%t%Set5.C&stomersE.Position =$;
t*id.bindingConte8tD%t%Set5.C&stomersE.PositionFF;
? .Net #ill not per"it Position propert to be set out of range
/hange of Position propert causes Position/hanged event to be fired ! use to
provide additional processing on "ove %e.g. to indicate #hen range li"it reached&
Comp!e' Binding
? )o"e controls %e.g. +ist6o4* /o"bo6o4* DataCrid& can be bound to "ore
than one record si"ultaneousl
;suall used to displa choices
/reate b setting Data)ource propert* either at design ti"e or via code
)o"e controls* such as +ist6o4 and /o"bo6o4* "ust be bound to single colu"n ! do
this b setting Displae"ber propert
Combo"o85.D%t%So&rce = D%t%Set5.C&stomers;Combo"o85.Dis1l%yMember = C&stomerD+;
i!tering and Sorting
? DataBie# per"its #or5ing #ith subset of data held #ithin DataTable
DataBie# provides "ethods for sorting and filtering data
DataBie# can update DataTable it represents
? /reate DataBie# ! can provide DataTable at construction* or later via Table
propert
D%t%4iew myD%t%4iew = new D%t%4iew(myD%t%0%ble);
Or
D%t%4iew myD%t%4iew = new D%t%4iew();myD%t%4iew.0%ble = myD%t%0%ble;
? /an create at design ti"e. Drag DataBie# fro" Data tab of Toolbo4 to
designer and set its Table propert in the properties #indo#
Use subject to ourTer"s and /onditions Written By 'oss Fruen
http://www.gsys.biz/Documents/Downloads/MCP/70-316http://www.gsys.biz/Documents/Downloads/MCP/70-316http://www.gsys.biz/homepages/rfruen/http://www.gsys.biz/homepages/rfruen/http://www.gsys.biz/Documents/Downloads/MCP/70-3168/12/2019 Microsoft Client Virtualization Strategy White Pape
19/22
6ind controls to DataBie# b setting the Data6indings properties in the Properties
#indo#
)orting acco"plished b setting )ort propert to appropriate colu"n na"e %or
"ultiple colu"ns separated b 8*9&. To sort descending append DE)/ to na"e
myD%t%4iew.Sort = C&stomerD+;myOt*er4iew.Sort = St%te/ City+;myDesc4iew.Sort = St%te D!SC/ City+;
? Filter data through 'o#Filter propert that ta5es string e4pression to be
evaluated #hen selecting records. 6uild co"ple4 e4pressions using AND* O'
and NOT together #ith arith"etic* concatenation and relational operations. 7N
and +7E operators per"it searches for specific strings.
myD%t%4iew.7ow?ilter = City = VSe%ttleI+;
myD%t%4iew.7ow?ilter = City = VDes MoinesI 2D (O0St%te =I2I)+;
myD%t%4iew.7ow?ilter = Price A5.$WX = 6$$+;
myD%t%4iew.7ow?ilter = City (VSe%ttleI/ V0%com%I/V"l%ineI);
myD%t%4iew.7ow?ilter = City ! VSeAtYeI+;
? Additional filtering provided b 'o#)tate propert that can ta5e 3 %or "ore&
of the follo#ing valueso ;nchanged ! displas ro#s that have not been changed
Added ! displas ro#s that have been added
Deleted ! displas ro#s that have been deleted
Origianl'o#s ! original ro#s including unchanged and deleted ro#s
/urrent'o#s ! current ro#s %including added* "odified and unchanged&
odified/urrent ! odified version of original data
odifiedOrigianl ! Original version
? DataBie# has properties that deter"ine if underling data can be edited. 6
default full editable* den access b setting appropriate propert to falseo Allo#Delete ! is deletion of ro#s in underling DataTable allo#ed
Allo#Edit ! is editing of ro#s in underling DataTable allo#ed
Allo#Ne# ! can ro#s be added to underling DataTable
? DataBie#anager is to Data)et #hat DataBie# is to DataTable.
DataBie#anager associated #ith Data)et and "anages DataBie# ob2ects for tables
contained #ithin Data)et
D%t%4iewM%n%ger myM%n%ger = newD%t%4iewM%n%ger(myD%t%Set);
Use subject to ourTer"s and /onditions Written By 'oss Fruen
http://www.gsys.biz/Documents/Downloads/MCP/70-316http://www.gsys.biz/Documents/Downloads/MCP/70-316http://www.gsys.biz/homepages/rfruen/http://www.gsys.biz/homepages/rfruen/http://www.gsys.biz/Documents/Downloads/MCP/70-3168/12/2019 Microsoft Client Virtualization Strategy White Pape
20/22
D%t%4iewM%n%ger myOt*erM%n%ger = newD%t%4iewM%n%ger();
myOt*erM%n%ger.D%t%Set = myOt*erD%t%Set;
? anage 'o#Filter* )ort* etc. through DataBie#)ettings collection
@@ Set 7ow?ilter 1ro1erty of D%t%4iew %ssoci%ted@@ wit* C&stomers t%blemyD%t%4iewM%n%ger.D%t%4iewSettingsC&stomers+E
.7ow?ilter = St%te = V92I+;
? /an retievde DataBie#s via /reateDataBie# "ethod ! re$uires reference to
DataTable
D%t%4iew myD%t%4iew;
myD%t%4iew =myD%t%4iewM%n%ger.Cre%teD%t%4iew(D%t%Set5.0%bles$E)
;
Lesson 5
Retrieving (m!Reader )rom S*!Command
? -"l'eader analogous to Data'eader class ! read onl* for#ard onl access to
-+ returned b $uer
-"l'eader %li5e Data'eader& re$uires e4clusive use of connection
)$l/o""and provides E4ecute-"l'eader "ethod to retrieve -+'eader ob2ect that
e4posed data fro" )$l/o""and as -+ ro#s
),+ $uer e4ecuted b )$l/o""and "ust contain FO' -+ clause
Al#as close -"l'eader to free /onnection
System.Zml.Zml7e%der my7e%der;S,lComm%nd mySKComm%nd = new S,lComm%nd(S!!C0 A
?7OM C&stomers ?O7 ZM 2T0O/ ZMD202+/S,lConnection5);
S,lConnection5.O1en();my7e%der = mySKComm%nd.!8ec&teZml7e%der();
w*ile(my7e%der.7e%d()):
@@ 9rite content %nd m%rN&1 of node %nd its@@ c*ildren
Console.9riteine(my7e%der.7e%dO&terZml());
my7e%der.Close();
Use subject to ourTer"s and /onditions Written By 'oss Fruen
http://www.gsys.biz/Documents/Downloads/MCP/70-316http://www.gsys.biz/Documents/Downloads/MCP/70-316http://www.gsys.biz/homepages/rfruen/http://www.gsys.biz/homepages/rfruen/http://www.gsys.biz/Documents/Downloads/MCP/70-3168/12/2019 Microsoft Client Virtualization Strategy White Pape
21/22
S,lConnection5.Close();
Reading (+, into DataSet
? ;se Data)et.'ead-"l to specif -+ file* strea"* -"l'eader or Te4t'eader
;se Data)et.'ead-"l)che"a to create Data)et #ith specified structure but no data
-riting (+, )rom DataSet
? ;se Data)et.
8/12/2019 Microsoft Client Virtualization Strategy White Pape
22/22
System.O.Stre%m9riter(myfile.t8t+);my0r%nsform.0r%nsform(myDoc&ment/ n&ll/ my9riter);
Use subject to ourTer"s and /onditions Written By 'oss Fruen
http://www.gsys.biz/Documents/Downloads/MCP/70-316http://www.gsys.biz/Documents/Downloads/MCP/70-316http://www.gsys.biz/homepages/rfruen/http://www.gsys.biz/homepages/rfruen/http://www.gsys.biz/Documents/Downloads/MCP/70-316