delphi2005探讨之四

2016-02-19 18:51 1 1 收藏

下面是个delphi2005探讨之四教程,撑握了其技术要点,学起来就简单多了。赶紧跟着图老师小编一起来看看吧!

【 tulaoshi.com - 编程语言 】

 

  笔者在用delphi2005调试其自带例子的DBWebFilterSample时遇到以下问题:若BdpDataAdapter1的active属性设为true,编译运行出现以下错
  误

  “/DBWebFilterSample”应用程序中的服务器错误。
  --------------------------------------------------------------------------------
  Connection open failed. unavailable database
  说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。
  异常详细信息: Borland.Data.Common.BdpException: Connection open failed. unavailable database源错误: 行 288:
  Self.DBWebDataSource1.ErrorDlgForeColor := System.Drawing.Color.Black;行 289:  Include(Self.Load, Self.Page_Load);行 290:
  (System.ComponentModel.ISupportInitialize(Self.BdpDataAdapter1)).EndInit;行 291:
  (System.ComponentModel.ISupportInitialize(Self.Employees)).EndInit;行 292:
  (System.ComponentModel.ISupportInitialize(Self.DataTable1)).EndInit;

  源文件: G:Program FilesBorlandBDS3.0DemosDelphi.NetDBWebWebFilterWebForm1.pas 行: 290 堆栈跟踪: [BdpException:
  Connection open failed. unavailable database]   Borland.Data.Provider.BdpDataAdapter.e() 
  Borland.Data.Provider.BdpDataAdapter.EndInit()   WebForm1.TWebForm1.InitializeComponent() in G:Program
  FilesBorlandBDS3.0DemosDelphi.NetDBWebWebFilterWebForm1.pas:290   WebForm1.TWebForm1.OnInit(EventArgs e) in
  G:Program FilesBorlandBDS3.0DemosDelphi.NetDBWebWebFilterWebForm1.pas:344 
  System.Web.UI.Control.InitRecursive(Control namingContainer)   System.Web.UI.Page.ProcessRequestMain()
  --------------------------------------------------------------------------------
  版本信息: Microsoft .NET Framework 版本:1.1.4322.573; ASP.NET 版本:1.1.4322.573 若BdpDataAdapter1的Active

   

  属性设为false,出现以下错误:
  “/DBWebFilterSample”应用程序中的服务器错误。
  --------------------------------------------------------------------------------
  输入字符串的格式不正确。
  说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。
  异常详细信息: System.FormatException: 输入字符串的格式不正确。源错误: 行 325:    else行 326:      sCurrentFilter :=
  Convert.ToString(o);行 327:    StartCustId := Convert.ToInt16(ListBox1.SelectedValue);行 328:    EndCustId :=
  Convert.ToInt16(ListBox2.SelectedValue);行 329:    if StartCustId EndCustId then
  源文件: G:Program FilesBorlandBDS3.0DemosDelphi.NetDBWebWebFilterWebForm1.pas 行: 327 堆栈跟踪: [FormatException:
  输入字符串的格式不正确。]   System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info) +0 
  System.Int16.Parse(String s, NumberStyles style, IFormatProvider provider) +37   System.Convert.ToInt16(String value) +19 
  WebForm1.TWebForm1.Page_Load(Object sender, EventArgs e) in G:Program
  FilesBorlandBDS3.0DemosDelphi.NetDBWebWebFilterWebForm1.pas:327   System.Web.UI.Control.OnLoad(EventArgs e) 
  System.Web.UI.Control.LoadRecursive()   System.Web.UI.Page.ProcessRequestMain()
  --------------------------------------------------------------------------------
  版本信息: Microsoft .NET Framework 版本:1.1.4322.573; ASP.NET 版本:1.1.4322.573

  
      由于我测试重点是用delphi2005实现web查询,对以上小错误稍加修改,编译运行不出现错误,但不显示任何数据。为了让其显示数据,笔者自
  行在webform1设计窗体加入一个按钮,在按钮事件中加入以下代码:
  if not BdpDataAdapter1.Active
  thenBdpDataAdapter1.Active:=true;
  编译运行点击此按钮,出现以下错误:
  “/DBWebFilterSample”应用程序中的服务器错误。
  --------------------------------------------------------------------------------
  Connection open failed. unavailable database
  说明: 执行当前Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。
  异常详细信息:
  Borland.Data.Common.BdpException: Connection open failed. unavailable database源错误: 行 301:
  if not BdpDataAdapter1.Active then行 303:
  BdpDataAdapter1.Active:=true;//此句出错行 304:
  end;
  源文件: G:Program
  FilesBorlandBDS3.0DemosDelphi.NetDBWebWebFilterWebForm1.pas 行: 303
  堆栈跟踪: [BdpException: Connection open failed.
  unavailable database] Borland.Data.Provider.BdpDataAdapter.e() Borland.Data.Provider.BdpDataAdapter.set_Active(Boolean value)
  WebForm1.TWebForm1.Button1_Click(Object sender, EventArgs e) in G:Program
  FilesBorlandBDS3.0DemosDelphi.NetDBWebWebFilterWebForm1.pas:303 System.Web.UI.WebControls.Button.OnClick(EventArgs e)
  System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
  System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
  System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
  System.Web.UI.Page.ProcessRequestMain()
  --------------------------------------------------------------------------------
  版本信息: Microsoft .NET Framework 版本:1.1.4322.573; ASP.NET 版本:1.1.4322.573

      仔细查阅帮助文件,BdpDataAdapter1的Active属性需设为true,但这么设置后也不行啊。肯定是数据库连接有问题,但在设计状态下测试数据
  库连接没有问题呀,于是把重新在按钮事件加入数据库连接所有属性,编译运行,点击,故障依旧。 再仔细查阅帮助文件,内有如下内容:To
  To set up a connection
   
  1.In Borland Data Provider: Connections Editor, select the appropriate item from the Connections list.
  2.In Connection Settings, enter the Database path.
  Note: If referring to a database on the local disk, prepend the path with
  localhost:. If using Interbase, for example, you would enter the path to your Interbase database:
  localhost:C:Program FilesBorlandInterbaseExamplesDatabaseemployee.gdb
  (or whatever the actual path might be for your system).

  3.Complete the UserName and Password fields for the database as needed.
  4.Click Test to confirm the connection.
  A dialog appears confirming the status of the connection.

  5.Click OK to return to the Borland Data Provider: Connections Editor dialog.
  6.Click OK to return to the Data Adapter Configuration dialog.
  In the Command tab, the areas for Tables and Columns are updated with information from your connection.

(本文来源于图老师网站,更多请访问https://www.tulaoshi.com/bianchengyuyan/)

  于是把BdpConnection1的ConnectionString属性设为databas=localhost:g:Program
  FilesBorlandInterbaseExamplesDatabaseemployee.gdb;assembly=Borland.Data.Interbase,Version=2.0.0.0,Culture=neutral,Public
  KeyToken=91d62ebb5b0d1b1b;vendorclient=gds32.dll;provider=Interbase;username=sysdba;password=masterkey
  BdpDataAdapter1的Active属性设为true

  去掉所加按钮及其代码,再次编译运行,一切正常。

(本文来源于图老师网站,更多请访问https://www.tulaoshi.com/bianchengyuyan/)

来源:https://www.tulaoshi.com/n/20160219/1619219.html

延伸阅读
Borland公司日前发布了其最新版Windows开发工具Delphi 2005,新版软件在同一开发环境中加入了对Win32、.Net、Delphi和C#的支持,同时集成了Borland应用生命周期管理工具。 代号Diamondback的新版Delphi是为支持Borland包罗万象的软件交付最优化计划设计的,该计划把商业流程自动化应用到了软件开发工具中。Borland一直希望自己能在.NE...
标签: SQLServer
一、 简介 在2005年11月份,微软发行了三种新产品系列:Visual Studio 2005,SQL Server 2005和.NET框架2.0(它包括ASP.NET 2.0)。SQL Server 2005是微软自从其上一个主要发行版本SQL Server 2000以来最新版本的数据库平台。在过去五年的发展中,SQL Server中加入了大量的新特征,所有这些新内容都被总结到微软网站的一篇文章《What's New...
标签: SQLServer
本文将解释如何在SQL Server 2005中以尽可能最简单的方法创建基于.NET的CLR子例程。本文主要针对在服务器端使用SQL Server 2005的.NET开发者。 一. 创建SQL Server 2005数据库 这一节主要讨论创建一个将用于本文中的数据库和表格。详见下列步骤: · 执行"Start-Programs-Microsoft SQL Server 2005-SQL Server Management S...
  Delphi中MIDAS线程模型   (1)Single      代表所产生的In-Process COM程序是一个单一线程的程序,一次只能接收一个client发出来的request,由于是循环的操作,所以不会有多任务同时进行的问题,你的COM程序不需要编写多任      务处理的部分.   (2)Apartment &...
标签: Delphi
  1.3.4.2 Shape部件         图形部件 Shape在前文中我们已有了解,它可以处理多种几何形状,通过设置 Pen 和 Brush的嵌套属性,可以设置图形边框颜色、线型及图形的风格、填充方式、贴图方式等。 1.3.4.3 PaintBox部件         在 System 页上...

经验教程

633

收藏

58
微博分享 QQ分享 QQ空间 手机页面 收藏网站 回到头部