ing a set of
individual references。 This causes a mismatch; and trying to bind to the two technologies is difficult。
So when you are writing database code; you are trying to automate the fitting of a square peg into a round
hole。 You get many extremely creative ideas and results; but at the end of the day; you are still fitting a square
peg into a round hole。
The essence of the problem when dealing with sets of data in a programming language is how to
integrate the two。 There is light at the end of the tunnel; in the form of programming language alterations
such as LINQ。 LINQ will be discussed in the next chapter。
Accessing Relational Databases
Regardless of the database implementation that you use; a mon architecture is employed;
as illustrated in Figure 14…1。
…………………………………………………………Page 398……………………………………………………………
376 CH AP T E R 1 4 ■ L E A R N I N G A B OU T R E L A TI O N AL DA TA B AS E D AT A
Figure 14…1。 mon database architecture
Most relational database servers are separate applications that run on their own。 To interact
with a running relational database; the database vendor provides a database driver。 In ; a
database driver is a piece of proprietary code that talks to the relational database server; but
exposes its functionality using the ADO layer。
The ADO layer is a technology that abstracts the database client into a neutral set of
interfaces。 By itself; ADO does not implement any technologies; but it defines the inter
faces that a database needs to have implemented。 ADO is similar to the lighting manager
application introduced in Chapter 8; where specific lighting implementations need to imple
ment interfaces。
The ADO code can be accessed directly in your application by your code。 However;
doing that means accessing the individual rows; columns; and database tables。 It is not a difficult
undertaking; but it means you need to do everything manually。 With respect to the lottery
example; it means manipulating the lottery winners and the lottery draws tables。
Visual Basic Express and other Visual Studio editions have a number of tools that will
generate code that automatically binds to tables and rows; reducing the amount of work that you
need to do。 In Figure 14…1; the user code has arrows pointing to both the Visual Studio–generated
code and the ADO code。 These arrows indicate that your code does not need to use the
Visual Studio–generated code; it is optional。 But the advantage of using the Visual Studio code
is that it reduces the amount of grunt work that your code needs to do。 The Visual Studio–
generated code is a thin functional layer on top of the ADO code that maps directly to the
tables that you are manipulating。
When you are developing an application that accesses a relational database; you need to
consider the following issues:
ADO drivers : When you write ADO code; you will need an ADO driver for
each database。 Thus; if you wish to use MySQL; you will need a MySQL driver。 However;
for the most part; the code that you write in your application will remain identical; regard
less of which type of database you are using。
Abstraction : There will always be differences in the code used to access different relational
databases。 Be prepared to abstract your database code if you access the database directly
using ADO。
…………………………………………………………Page 399……………………………………………………………
C HA P TE R 1 4 ■ L E AR N I N G AB O U T R E L AT IO N A L D AT AB A SE D A TA 377
Designing a Database Using Visual Basic Express
Visual Basic Express is very helpful when designing and building database applications。 It provides
interface…based tools for designing the database; managing connections; and managing data
access。
With Visual Basic Express; you can directly integrate the ADO drivers for only Microsoft
SQL Server。 (This does not mean you cannot use a different ADO driver using code。) If you
want to use the GUI tools for a database driver other than for SQL Server; you will need to upgrade
your Visual Studio edition。 For this chapter’s examples; we’ll use the SQL Server Express Edition
driver (http://msdn。microsoft。/vstudio/express/sql/)。
You can add the GUI tool…based database support to any Visual Basic project type。 For this
chapter; we’ll use a console project called DatabaseConsoleEx。
After you have created the DatabaseConsoleEx console project in Visual Basic Express
(using the procedure outlined in Chapter 1); you can set up the database; and then add tables
to your new database。
Configuring the Data Source
Using the Visual Basic Express Data Source Configuration Wizard; you can add a database as
your data source; set up the database connection; and select database objects to include in the
project。 Follow these steps to use the wizard:
1。 Select Data Add New Data Source to start the Data Source Configuration Wizard。
2。 Choose Database as the data source and click Next。
3。 You’re asked to choose a data connection。 When choosing the data connection; you are
defining the connection settings to your relational database。 Since we are creating a
new database in this example; click the New Connection button。
4。 Choose Microsoft SQL Server Database File and click Continue。
5。 In the Add Connection dialog box; fill in the database file name。 For this example; enter
the name lot
小说推荐
- oracle从入门到精通(PDF格式)
- -Page 1-Oracle 从入门到精通-Page 2-资源来自网络,仅供学习 Oracle 从入门到精通一、SQL 8
- 最新章:第37章
- C语言游戏编程从入门到精通(PDF格式)
- -Page 1-Page 2-Page 3-Page 4-Page 5-Page 6-Page 7-Page 8-Page 9-Page 10-Page 11-Page 12-Page 13-Page 14
- 最新章:第4章
- Java编程思想第4版[中文版](PDF格式)
- -Page 1-Page 2《Thinking In Java》中文版作者:Bruce Eckel主页:http/BruceEckel.编译:Trans Bot主页:http/memberease~transbot致谢-献给那些直到现在仍在孜孜不倦创造下一代计算机语言的人们!指导您利用万维网的语言进
- 最新章:第295章
- 深入浅出MFC第2版(PDF格式)
- -Page 1-Page 2-山高月小山高月小 水落石出水落石出山高月小山高月小 水落石出水落石出-Page 3-深入淺出MFC(第版 使用Visual C 5.0 MFC 4.2)Dissecting MFC(Second Edition Using Visual C 5.0 MFC 4.2)侯俊
- 最新章:第309章
- VC语言6.0程序设计从入门到精通
- -Page 1-Visual C 6.0 程序设计从入门到精通求是科技 王正军 编著
- 最新章:第136章
- SQL 21日自学通(V3.0)(PDF格式)
- -Page 1-SQL 21 日自学通(V1.0 翻译人 笨猪目录目录 1译者的话 14第一周概貌 16从这里开始 16
- 最新章:第170章
- 2008年青年文摘精编版
- 作者:中国青年出版社“初恋”的惩罚.作者:凡 凡 文章来源《真情》2005年第4期 点击数:6608 更新时间:2005-6-5过了年,我就十八岁了。离高考只剩下四个多月了。这一段,班里的男女生相互间递纸条、写情书、约会等地下活动慢慢的多了起来。我这个“尖子生”也突然感到了不安、慌乱,并且自责。不知
- 最新章:第230章
- JMS简明教程(PDF格式)
- -Page 1-JMS1.1规范中文版卫建军2007‐11‐22-Page 2
- 最新章:第28章
- SQL语言艺术(PDF格式)
- -Page 1-SQLSSQQLL语言艺术内容介绍本书分为12章,每一章包含许多原则或准则,并通过举例的方式对原则进行解释说明。这些例子大多来自于实际案例,对九种SQL经典查询场景以及其性能影响讨论,非常便于实践,为你数据库应用维护人员阅读。资深 SQL 专家 Stéphane Faroult倾力打
- 最新章:第27章