Podobne
- Strona startowa
- PHP and MySQL MySQL Bible
- McGraw.Hill,.Digital.Animation.Bible.Creating.Professional.Animation.with.3ds.Max.Lightwave.and.Maya.(2004).LiB
- [eBook] DirectX 3D Graphics Programming Bible
- What Does a Martian Look Like The Science of Extraterrestrial Life by Jack Cohen & Ian Stewart (2002)
- Honda Catálogo De Peças Cg Titan 125 Ks Es 2000 A 2002
- Windows XP Bible
- Photoshop 6 Bible (eBook)
- Redhat Linux 7.2 Bible
- Dreamweaver MX Bible
- ÂŚwietlisty Kamień 03 Paneb Ognik Jacq Christian(1)
- zanotowane.pl
- doc.pisz.pl
- pdf.pisz.pl
- prymasek.xlx.pl
Cytat
Do celu tam się wysiada. Lec Stanisław Jerzy (pierw. de Tusch-Letz, 1909-1966)
A bogowie grają w kości i nie pytają wcale czy chcesz przyłączyć się do gry (. . . ) Bogowie kpią sobie z twojego poukładanego życia (. . . ) nie przejmują się zbytnio ani naszymi planami na przyszłość ani oczekiwaniami. Gdzieś we wszechświecie rzucają kości i przypadkiem wypada twoja kolej. I odtąd zwyciężyć lub przegrać - to tylko kwestia szczęścia. Borys Pasternak
Idąc po kurzych jajach nie podskakuj. Przysłowie szkockie
I Herkules nie poradzi przeciwko wielu.
Dialog półinteligentów równa się monologowi ćwierćinteligenta. Stanisław Jerzy Lec (pierw. de Tusch - Letz, 1909-1966)
[ Pobierz całość w formacie PDF ]
.TipYou can add a view to a stored procedure.Using parameters with a stored procedureIf you want to run a stored procedure with different criteria values every time yourun it, you can add a parameter to the stored procedure s criteria.A parameter is aplace-holder for the column s criteria.For example, you may want to retrieve allpets that are a certain type of animal.But, you may want to retrieve all rabbit-typepets one time, or all pets that are dogs another time.The All Pets For Type storedprocedure uses the Pet_Type parameter, as shown in Figure 34-13.Figure 34-13: Creating a stored procedure with a parameter3596-X ch34.F 5/30/01 11:49 AM Page 1164Part VI &' Access and the External World1164NoteYou can t specify a parameter in a view.Using a stored procedure to update dataWhile views support only Select queries, stored procedures support action queriesas well as Select queries.An action query is a stored procedure that inserts, modi-fies, or deletes data by using the SQL INSERT, UPDATE, and DELETE statements.The Update Medication Prices stored procedure, shown in Figure 34-14, is an exam-ple of an Update action query.The Update Medication Prices stored procedure increases each of the values in thePrice column in the Medications table by 10 percent.Notice that the Grid pane ofthe stored procedure contains different columns than the columns shown in theSelect query examples.To create an action query using the Query Designer, selectthe Query menu item.Then choose the type of action query that you want to cre-ate: Make-Table, Update, Append, Append Values, or Delete.Figure 34-15 shows theoptions for the Query menu item.Figure 34-14: An Update action query3596-X ch34.F 5/30/01 11:49 AM Page 1165Chapter 34 &' Working with Access Projects1165Figure 34-15: Using the Query Designer to create an action queryCreating user-defined functionsUser-defined functions combine the best features of views and stored proceduresinto a single query.NewYou can pass parameters to user-defined functions.They also can include views,Featurestored procedures, or other functions.User-defined functions can t be used toupdate data in a table.To create a function, select the Queries object, then select Create function indesigner.The Query Designer opens.You can add a table, a view, or another func-tion to the new function by selecting from the list of tables, views, and functionsshown in the Show Table window.The design for the Pets for Type function, shown in Figure 34-16, looks just like thedesign for the All Pets For Type stored procedure.3596-X ch34.F 5/30/01 11:49 AM Page 1166Part VI &' Access and the External World1166Figure 34-16: Creating a user-defined functionBasically, the user-defined function is a simpler version of the stored procedure.Ifyour query needs to accept one or more parameters and return a single value or asingle table, you should use a user-defined function for the query rather than astored procedure.Stored procedures are geared for performing more complexquery operations, such as multiple Select statements, table updates, and returningmultiple result sets.Using Unbound FormsAccess projects allow you to bind a form s Record source directly to a table.Abound form is a form that s tied directly to a table or query, providing a constantopen connection to all of the data in the table or query.Although this approach is aquick and easy way to present and update data on the form, this is not the mostefficient way to work with data in the client/server world.Bound forms maintain a constant connection between the server and the worksta-tion.The server must maintain a record lock on the data displayed on the form even if the user is simply viewing it.Open connections and record locks consumeserver resources.If you are operating in an environment with many users or whereusers are working with large volumes of data and transactions, you want to useunbound forms.3596-X ch34.F 5/30/01 11:49 AM Page 1167Chapter 34 &' Working with Access Projects1167An unbound form is a form that doesn t maintain a constant open connection to atable or query.You retrieve data from a table or query one record at a time.Theload on the server is significantly reduced because it doesn t need to maintain openconnections or record locks.Here are some common reasons to implement unbound forms:&' Improved performance due to retrieval of a minimal amount of data&' Improved control of record-locking conflicts&' Bypasses Access automatic record saving, providing ability to confirm savingor canceling record changes&' Required for database security considerationsVisual Basic code is used to handle all of the data used in the form.You must writea procedure to handle searching for and displaying the data.You must write otherprocedures to handle updating the data.The following list covers most of the tasksthat a typical unbound form needs to handle:&' Retrieving the set of data to be viewed or edited on the form&' Loading the data into the form s controls&' Searching for another record&' Determining when data on the form has changed&' Saving changed data&' Undoing changes to data&' Moving to other records in the set (first, last, next, previous)&' Creating a new recordCreating the code for each of these tasks may seem like a lot of work.But if youwant to build a true client/server application, this is the best approach.Working with unbound formsCreating the Visual Basic functions to display and process data in an unbound formrequires the use of the ActiveX Data Objects (ADO) programming model.ADOenables you to write an application to access and manipulate data in a databaseserver through an OLE DB provider.ADO s primary benefits are ease of use, highspeed, low memory overhead, and a small hard drive footprint.ADO supports keyfeatures for building client/server and Web-based applications.Cross- See Chapter 31 to review the basic concepts of the ADO programming model.Reference3596-X ch34.F 5/30/01 11:49 AM Page 1168Part VI &' Access and the External World1168For an example of a working unbound form, we use the Customers Unbound form.Figure 34-17 shows the Customers Unbound form in Normal view.Figure 34-17: Viewing data in an unbound formThe Customers Unbound form demonstrates virtually any function you need toadd, edit, delete, and find records.The buttons in the form s footer section performthese functions.The Undo button allows the user to restore the original data for therecord after changes have been made but before the Save button is selected.ThePrint button opens a print dialog that provides several choices for printing theform s data.The Save button allows the user to immediately process changes madeto the data.NoteIn bound forms, changes are saved automatically when the user closes the form ormoves to another record
[ Pobierz całość w formacie PDF ]