⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ch08.htm

📁 好书《C++ Builder高级编程技术》
💻 HTM
📖 第 1 页 / 共 5 页
字号:
<P>To get connected to Oracle or Sybase, the first thing to do is close BCB and all
the Borland tools, and consult the manuals for your server. They will show you how
to get the server set up, how 
to test the connection, and how to run some tools for
managing your database. Once this part of the procedure is over, you can launch BCB,
and you should be able to connect right away after establishing an alias. Aliases
are described in the next 
section of this chapter, and in- depth in several of the
upcoming chapters, including Chapter 15, &quot;Working with the Local InterBase Server.&quot;
They are also discussed in the readme file from the CD that accompanies this book.
Of course, you 
have to have the client/server version of Delphi to connect to these
databases.</P>
<P>There is a Sams Publishing book called the Database Developer's Guide with Delphi
2 (Ken Henderson, ISBN 0-672-30862-2), which goes into considerable depth on 
connecting
to most of the major servers. The portion of the book you want to see is Chapter
24, &quot;Delphi's Database Drivers Demystified.&quot; Almost anything this book
says about Delphi databases will apply equally to BCB's databases. Delphi and 
BCB
are sister and brother tools, and their approach to databases is almost identical.</P>
<P>I will, however, go to some lengths to ensure you are properly connected to InterBase,
when I introduce that topic in Chapter 15. Until that time, there is 
no need for
you to be connected to InterBase while reading this book. I should add, however,
that connecting to InterBase is a simple task that should have been done for you
automatically during the install of BCB. To check whether you are properly 
connected,
try using the <TT>IBLOCAL</TT> alias set up by the install program for connecting
to an InterBase table called <TT>Employee.gdb</TT>.
<H3><A NAME="Heading32"></A><FONT COLOR="#000077">Aliases</FONT></H3>
<P>You can create aliases inside any 
one of three tools:

<UL>
	<LI>The SQL Explorer accessed through the Database | Explore menu option. From inside
	this tool, choose Object | New to create an alias.
	<P>
	<LI>The Database Desktop. This is a stand-alone program installed by default in 
the
	<TT>Program Files\Borland\Database Desktop</TT> directory. Choose Tools | Alias Manager
	from the DBD menu to create an alias.
	<P>
	<LI>The <TT>BDECFG32.exe</TT> program found in the directory where the BDE is installed.
	Turn to the Alias page 
in this program to create an alias.
</UL>

<P>Both Paradox and InterBase aliases are created automatically when you install
BCB. You can study these aliases as guides when creating your own aliases. Also see
the readme files on the CD that accompanies 
this book, and the section on creating
ODBC aliases near the end of this chapter.</P>
<P>Various installation programs, such as Wise from Great Lakes Business Software
(<A HREF="javascript:if(confirm('http://www.glbs.com/  \n\nThis file was not retrieved by Teleport Pro, because it is addressed on a domain or path outside the boundaries set for its Starting Address.  \n\nDo you want to open it from the server?'))window.location='http://www.glbs.com/'" tppabs="http://www.glbs.com/"><TT>www.glbs.com</TT></A>, Tel (313) 981-4970, Fax

(313) 981-9746) and InstallShield, can create aliases for you automatically. If you
need to add aliases to a client machine during installation, you should let one of
these programs handle it for you. They will also automate the installation of the

BDE. InstallShield Express ships in the ISX directory found on some versions of the
BCB CD.
<H3><A NAME="Heading33"></A><FONT COLOR="#000077">Some Notes on Installing TCP/IP</FONT></H3>
<P>In this section I briefly discuss the process of setting up 
TCP/IP on a Windows
95 machine. The process should be nearly identical on a Windows NT 4.0 machine, though
the dialogs might have a slightly different name or appearance.</P>
<P>TCP/IP is the protocol of choice when connecting to client/server 
databases. It
ships automatically with the 32-bit Windows products. To see if it is installed on
your system, open the Control Panel and launch the Network applet. If you have TCP/IP
installed, it will show up on the Configuration page of this applet, 
as shown in
Figure 8.12.<BR>
<BR>
<A NAME="Heading34"></A><A HREF="08ebu12.jpg" tppabs="http://pbs.mcp.com/ebooks/0672310228/art/08/08ebu12.jpg">FIGURE 8.12.</A><FONT COLOR="#000077">
</FONT><I>The TCP/IP information from the Control Panel.</I></P>
<P>If TCP is not installed, you should push the Add button 
on the Configuration page
and bring up the Select Network Component Type dialog. Select Protocol from the list
of drivers, and again choose the Add button. In the Select Network Protocol dialog,
choose Microsoft in the left-hand list box, and TCP/IP 
in the right-hand list box.
Windows will then install the necessary software, which may require the use of your
Windows Install CD-ROM.</P>
<P>You will probably also have to specify an IP address, subnet mask, gateway, and
DNS server. This information 
can be garnered from your network administrator. If
you are working on a small local network with Windows machines that you have set
up in your office or home, you can ignore the DNS server, and can make up your own
IP address, subnet mask, and 
gateway. For instance, the following numbers would do,
as long as you are not connected to the real Internet, and are only talking to the
machines in your home or office:</P>
<PRE><FONT COLOR="#0066FF">IP Address: 143.186.186.2

Subnet mask: 
255.255.255.0

Gateway: 143.186.186.1

</FONT></PRE>
<P>The other machines on your network should have the same subnet and gateway, but
the IP address should be unique. For instance, the next machine should have an IP
address of 
<TT>143.186.186.3</TT>, and then <TT>143.186.186.4</TT>, and so on. Remember,
don't make up your own numbers if you are connected to the real Internet! If you
have an Internet connection, contact your network administrator or Internet service
provider 
(ISP).

<DL>
	<DT></DT>
</DL>



<BLOCKQUOTE>
	<P>
<HR>
<FONT COLOR="#000077"><B>NOTE:</B></FONT><B> </B>If you are appalled by my suggestion
	that people make up their own IP addresses, you should remember that many people
	connect their machines 
without being on the Internet. I do this all the time with
	two laptops when I am on the road showing BCB and Delphi. I also have a network at
	home with machines on it that are never connected directly to the Net. <BR>
	<BR>
	I want to stress, 
however, that if you are connected to the Internet, it is very
	simple to ask your IS department for an IP address for your computer. There are plenty
	of IP addresses in this world, and everyone can afford to have several for their
	own use. 
<HR>



</BLOCKQUOTE>

<P>To check whether you are connected properly, open up a DOS window and try to ping
one of the machines in your network. Ping is a built-in application that ships with
Windows 95 and Windows NT. If you installed TCP/IP as explained 
previously, ping
will be set up on your machine.</P>
<P>To get started, you can try to ping yourself:</P>
<PRE><FONT COLOR="#0066FF">Ping 143.186.186.2

</FONT></PRE>
<P>Here is a built-in address for referencing your own machine:</P>
<PRE><FONT 
COLOR="#0066FF">Ping 127.0.0.1

</FONT></PRE>
<P>Or you can try to ping one of the other machines in your network:</P>
<PRE><FONT COLOR="#0066FF">Ping 143.186.186.3

</FONT></PRE>
<P>Here is the result of successful session:</P>
<PRE><FONT 
COLOR="#0066FF">c:\4dos&gt;ping 143.186.186.2

Pinging 143.186.186.2 with 32 bytes of data:

Reply from 143.186.186.2: bytes=32 time=55ms TTL=32

Reply from 143.186.186.2: bytes=32 time=1ms TTL=32

Reply from 143.186.186.2: bytes=32 time=1ms TTL=32


Reply from 143.186.186.2: bytes=32 time=1ms TTL=32

c:\4dos&gt;

</FONT></PRE>
<P>Here is the result of a failed session:</P>
<PRE><FONT COLOR="#0066FF">c:\4dos&gt;ping 143.186.186.3

Pinging 143.186.186.3 with 32 bytes of data:

Request timed out.


Request timed out.

Request timed out.

Request timed out.

c:\4dos&gt;

</FONT></PRE>
<P>Failed sessions usually occur because your machine is not configured properly
or else the wires connecting you to the network are not set up correctly. (For 
instance,
you might have forgotten to plug into the network!)</P>
<P>If you are attached to the Internet and have a DNS server, you can try to ping
one of the big servers on the Net:</P>
<PRE><FONT COLOR="#0066FF">Ping compuserve.com

</FONT></PRE>

<P>Here is successful session:</P>
<PRE><FONT COLOR="#0066FF">c:\&gt;ping compuserve.com

Pinging compuserve.com [149.174.207.12] with 32 bytes of data:

Reply from 149.174.207.12: bytes=32 time=298ms TTL=239

Reply from 149.174.207.12: bytes=32 
time=280ms TTL=239

Reply from 149.174.207.12: bytes=32 time=333ms TTL=239

Reply from 149.174.207.12: bytes=32 time=332ms TTL=239

c:\&gt;

</FONT></PRE>
<P>Pinging <TT>compuserve.com</TT> is the same thing as pinging <TT>149.174.207.12</TT>.
In 
fact, it's the job of the DNS server (the Domain Name Server) to resolve a human-readable
name such as <TT>compuserve.com</TT> into an IP address.</P>
<P>If you want to create a human-readable IP address on a local office or home network,
you can edit 
the <TT>HOSTS</TT> files that ship with Windows 95 or Windows NT. Under
Windows 95, you will find a sample <TT>HOSTS</TT> file called <TT>Hosts.sam</TT>
in your Windows directory. Here is what this file looks like:</P>
<PRE><FONT COLOR="#0066FF"># 
Copyright (c) 1994 Microsoft Corp.

#

# This is a sample HOSTS file used by Microsoft TCP/IP for Chicago

#

# This file contains the mappings of IP addresses to host names. Each

# entry should be kept on an individual line. The IP address should

# 
be placed in the first column followed by the corresponding host name.

# The IP address and the host name should be separated by at least one

# space.

#

# Additionally, comments (such as these) may be inserted on individual

# lines or following 
the machine name denoted by a `#' symbol.

#

# For example:

#

#      102.54.94.97     rhino.acme.com          # source server

#       38.25.63.10     x.acme.com              # x client host

127.0.0.1 localhost

</FONT></PRE>
<P>You can rename 
this file to <TT>HOSTS.</TT> with no extension, and then add your
own list of IP address to it:</P>
<PRE><FONT COLOR="#0066FF">143.186.186.3 MarysPC

143.186.186.4 MikesPC

</FONT></PRE>
<P>After doing this, you can ping the other machines with a 
human-readable name:</P>
<PRE><FONT COLOR="#0066FF">ping maryspc

</FONT></PRE>
<H3><A NAME="Heading36"></A><FONT COLOR="#000077">Connecting to ODBC</FONT></H3>
<P>ODBC is a popular means of connecting to databases. For many developers, ODBC
plays the 
same role in their development that the BDE plays in the life of Borland
developers. ODBC is so popular that Borland has added a high-p

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -