📄 80254.htm
字号:
<html xmlns="http://www.w3.org/TR/xhtml1/strict"> <head> <title>天极网</title> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"></meta> <meta http-equiv="Pragma" content="no-cache"></meta> <meta http-equiv="expires" content="Mon,12 May 1998 00:36:05 GMT"></meta> <link rel="stylesheet" href="/xslimages/css/cpcw.css"></link> </head> <style>.nava { font-size: 9pt}.font1{font-size: 10.5pt}</style> <body bgcolor="#FFFFFF" topmargin="2"><table width="760" border="0" cellspacing="0" cellpadding="0" align="center"><tr><td width="20%" rowspan="3" valign="top" align="center"><table width="95%" border="1" cellspacing="0" cellpadding="0" height="60" bordercolorlight="#CCCCCC" bordercolordark="#FFFFFF"><tr valign="middle" align="center"><td><div align="center"><span class="nava">天极硬件,新闻及时<br>资料详尽,敬请关注<br><a href="/33554432/35651584/yingjian.htm">www.myhard.com</a></span></div></td></tr></table></td><td width="57%" valign="bottom" rowspan="3" align="center"><div align="center"><script language="JavaScript" src="http://ad.cpcw.com/js/school.js"></script></div></td><td width="20%" valign="top" rowspan="3" align="center"><table width="95%" border="1" cellspacing="0" cellpadding="0" height="60" bordercolorlight="#CCCCCC" bordercolordark="#FFFFFF"><tr valign="middle" align="center"><td><div align="center"><span class="nava">好又多电子商务<br>让您一点动心<br><a href="http://www.hoyodo.com">www.hoyodo.com</a></span></div></td></tr></table></td></tr><tr></tr><tr></tr></table><table width="760" border="0" cellspacing="0" cellpadding="0" height="70" align="center"><tr><td width="145" valign="bottom" rowspan="3"><img src="/xslimages/content/logo.gif" width="140" height="60"></img></td><td colspan="3" width="100%" height="33" align="center"><a href="/" target="_blank">首页</a>| <a href="/33554432/36700160/news.htm" target="_blank">新闻中心</a>| <a href="/33554432/50331648/business.htm" target="_blank">企业中心</a>| <a href="/33554432/41943040/caijing.htm" target="_blank">财经中心</a>| <a href="/33554432/39845888/fashion.htm" target="_blank">时尚中心</a>| <a href="/33554432/35651584/yingjian.htm" target="_blank">硬件中心</a>| <a href="/33554432/34603008/school.htm" target="_blank">学习中心</a>| <a href="/33554432/37748736/game.htm" target="_blank">游戏中心</a>| <a href="/33554432/38797312/ziyuan.htm" target="_blank">资源中心</a>| <a href="http://www.hoyodo.com/" target="_blank">社区</a>| <a href="http://training.yesky.com/" target="_blank">网校</a></td></tr><tr><td colspan="3" width="78%" height="20" align="right"><b>中心栏目:<a href="http://www.mydown.com" target="_blank"><font color="#FF0000"><u>红辣椒软件下载</u></font></a></b><a href="http://soft.yesky.com" target="_blank"> 软件之窗 </a><a href="http://desktop.yesky.com" target="_blank">天极桌面网 </a><a href="http://art.yesky.com" target="_blank">美工教室 </a><a href="http://itdreamer.yesky.com" target="_blank">程序方舟 </a><a href="http://homepage.yesky.com" target="_blank">网页陶吧 </a><a href="http://safe.yesky.com" target="_blank">安全之路</a><a href="http://soft.yesky.com" target="_blank"></a></td></tr></table><table align="center" border="0" cellpadding="0" cellspacing="0" width="760"><tbody><tr bgcolor="#333333"><td colspan="2" height="1"></td></tr><tr><td bgcolor="#ff9900" height="16" valign="bottom" width="72%"><font color="#000000"><b><font color="#ffffff">学 习 中 心</font></b></font></td><td bgcolor="#6699cc" height="16" width="28%"><div align="center"><font face="Arial, Helvetica, sans-serif"><b><font color="#ffffff">N E T S C H O O L</font></b></font></div></td></tr><tr bgcolor="#333333"><td colspan="2" height="1"></td></tr></tbody></table><table align="center" border="0" cellpadding="0" cellspacing="0" width="760" bgcolor="#eeeeee"><td colspan="2" height="28"><div align="center"><a href="/33554432/34603008/34635776/34636800/34636832/schoolinverse1.htm" target="_blank"><font color="#000000">HTML</font></a><font color="#000000"> _</font><a href="/33554432/34603008/34635776/34636800/34636864/schoolinverse1.htm" target="_blank"><font color="#000000">JavaScript</font></a><font color="#000000"> _</font><a href="/33554432/34603008/34635776/34636800/34636928/schoolinverse1.htm" target="_blank"><font color="#000000">CSS</font></a><font color="#000000"> _ <a href="/33554432/34603008/34635776/34637824/34637952/schoolinverse1.htm" target="_blank"><font color="#000000"> PHP </font></a><font color="#000000"> _ </font></font><a href="/33554432/34603008/34635776/34637824/34637888/schoolinverse1.htm" target="_blank"><font color="#000000">ASP</font></a><font color="#000000"> _</font><a href="http://www.yesky.com/33554432/34603008/34635776/34637824/34637920/schoolinverse1.htm" target="_blank"><font color="#000000">Perl</font></a><font color="#000000"> _</font><a href="/33554432/34603008/34635776/34638848/34638880/schoolinverse1.htm" target="_blank"><font color="#000000">Dreamweaver</font></a><font color="#000000"> _</font><a href="/33554432/34603008/34635776/34639872/34639904/schoolinverse1.htm" target="_blank"><font color="#000000">XML</font></a><font color="#000000"> _</font><a href="http://www.yesky.com/33554432/34603008/34734080/schoolinverse2.htm" target="_blank"><font color="#000000">病毒</font></a><font color="#000000"> _</font><a href="http://www.yesky.com/67108864/68157440/68419584/inverse2.htm" target="_blank"><font color="#000000">程序开发</font></a><font color="#000000"> _</font><a href="http://www.yesky.com/33554432/34603008/34799616/34800640/schoolinverse1.htm" target="_blank"><font color="#000000">Email</font></a><font color="#000000"> _</font><a href="http://www.yesky.com/33554432/34603008/34897920/34898944/schoolinverse1.htm" target="_blank"><font color="#000000">Windows 9x</font></a><font color="#000000"> _</font><a href="/33554432/34603008/34897920/34900992/schoolinverse1.htm" target="_blank"><font color="#000000">Linux</font></a><font color="#000000"> _</font><a href="/33554432/34603008/34963456/34966528/schoolinverse1.htm" target="_blank"><font color="#000000">WPS</font></a><font color="#000000"> _</font><a href="http://www.yesky.com/33554432/34603008/34963456/34964480/schoolinverse1.htm" target="_blank"><font color="#000000">Word</font></a></div></td></table><table width="760" border="0" cellspacing="0" cellpadding="0" height="30" align="center"><tr><td align="left" valign="bottom"><span class="nava"><span class="nava"><a href="/index.htm">首页</a>→ <a href="/33554432/34603008/school.htm">学习中心</a>→ <a href="/33554432/34603008/34668544/schoolinverse2-pro.htm">程序方舟</a>→ <a href="/33554432/34603008/34668544/34672640/schoolinverse2.htm">技巧经验</a>→ <a href="/33554432/34603008/34668544/34672640/34672672/schoolinverse1.htm">DELPHI技巧</a>→ </span></span></td><td width="2%"></td></tr></table><table width="760" border="0" cellspacing="0" cellpadding="0" align="center"><tr><td colspan="3" valign="top" width="75%"><table width="98%" border="0" cellspacing="1" cellpadding="1" bgcolor="#000000"><tr bgcolor="#FFFFFF"><td width="100%" colspan="4" align="left"><table width="95%" align="center"><tr><td class="font1"><p align="center"><br><font size="3">用Delphi编程访问SQLServer数据库</font><br><span class="nava"><font color="#CC9933">2000-06-14· -·中国计算机报社</font></span></p> Delphi是一个优秀的可视化软件开发环境,并已广泛应用于数据库软件的开发。在DelphiC/S版环境中,结合其优化的数据库操作,以及Borland Database Engine(即:BDE,数据库引擎),对开发客户机/服务器系统下的网络数据库软件提供了更加快速有效的途径。在客户机/服务器系统中,服务器端我们采用Microsoft SQL Server6.0 for WindowsNT作为数据库服务器;另外,在客户端采用Delphi编写客户软件。在此,我们假定SQLServer设置完毕,并已经启动,仅介绍客户端的程序编写步骤。从以下文章中,读者可以发现不需要写一句程序,就能实现对SQL Server数据库的操作了。具体步骤如下:<br> <br> 第一步,注册ODBC数据源。这是至关重要的一步,否则就无法实现对数据库的访问。例如,我们定义一个可访问SQL Server服务器上zhb数据库的数据源ZHB。首先,选择SQL Server类型的数据库,进入“ODBC SQL Server Setup”窗口。然后,定义数据源名称为“ZHB”;定义Server为“SQL—Server”;以及网络路径为“ιιSQL—Server”;最后,按option命令按钮选择访问的数据库为zhb即可。<br> <br> 第二步,配置BDE。它是Delphi专用的数据库引擎。既可以从Delphi程序组里启动,也可以从Delphi程序项的Tools菜单下启动。Delphi在访问SQL Server数据库时略不同于VB。VB是直接调用ODBC来连接SQLServer的,而Delphi是首先调用BDE中的别名,别名再通过BDE中的ODBC Driver直接访问ODBC数据源实现的。而在BDE的ODBC Driver中你还可以定义其他ODBC属性,例如语言驱动程序或打开模式等等。这无疑大大增强了ODBC的功能。<br> <br> 首先,在Drivers标记页中,按“New ODBC Driver”添加新的驱动程序。在添加窗口中有三栏需要填写。第一栏SQL Link Driver可任取一名,如:ODBC—ZHB;第二栏Default ODBC Driver中选择SQL Server;在第三栏default Data Source Name中选择刚才注册的数据源ZHB。按OK确认后就增加了一个名为ODBC—ZHB的DelphiODBC驱动程序。在其右侧的参数表中,还可以设置打开模式OPENMODE、查询模式SQLQRYMODE、SQL语句执行模式SQL?PASSTHRUMODE以及语言驱动程序LANGDRIVER等。接下来,在Aliases标记页中,按“NewAlias”命令按钮增加一个新的别名。在增加新别名窗口中有两栏需要填写。第一栏为Newaliasname,可任取一个名字,如:zhbdb;这个别名就是我们要在Table控件中直接调用的数据库名字。第二栏Aliastype选择刚才在Drivers标记页中定义的ODBC—ZHB,最后按OK确认,就增加了一个名为zhbdb的别名。这样,Table控件可以通过别名zhbdb,别名zhbdb通过Delphi的ODBCDrivers(即:ODBC—ZHB),ODBC—ZHB再通过ODBC数据源ZHB就可连接到SQL—Server服务器上的zhb数据库了。以上相当于完成了在BDE中的注册,接下来就可以进行控件的属性设置了。<br> <br> 第三步,设置Data Access控件属性以实现与数据库的连接。将Table和DataSource控件加到窗体中并修改Table控件的属性。首先,将DatabaseName属性改为刚才在BDE别名中定义的zhbdb。设置完databaseName属性后,就可以从TableName属性的下拉列表中选择一个表的名字。这其间Table控件要完成与数据库的连接,连接成功后,该列表中才会出现可选的表名。然后,将Active属性改为true,将打开的数据库激活,和DataSource控件建立联系。将Exclusive属性改为true。最后,将DataSource控件的DataSet属性设为Table1。DataSource控件为Table控件与DataControls控件相联系的渠道。通过以上步骤的设置,DataSource1对象就与zhb数据库的某个表建立了联系。以后,只要对DataSource1对象访问,就可以实现对该表的操作了。<br> <br>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -