When I use delphi2005 to debug the DBWebFilterSample with its own example, I encountered the following problem: If the active property of BdpDataAdapter1 is set to true, the following error occurs when the compilation and operation is completed.
error
Server error in the "/DBWebFilterSample" application.
-------------------------------------------------- ------------------------------
Connection open failed. unavailable database
Description: An unhandled exception occurred during the execution of the current web request. Please check the stack trace information for details about the error and where the error was caused in the code.
Exception details: Borland.Data.Common.BdpException: Connection open failed. unavailable database source error: Line 288:
Self.DBWebDataSource1.ErrorDlgForeColor := System.Drawing.Color.Black; Line 289: Include(Self.Load, Self.Page_Load); Line 290:
(System.ComponentModel.ISupportInitialize(Self.BdpDataAdapter1)).EndInit;Line 291:
(System.ComponentModel.ISupportInitialize(Self.Employees)).EndInit;Line 292:
(System.ComponentModel.ISupportInitialize(Self.DataTable1)).EndInit;
Source file: G:/PRogram Files/Borland/BDS/3.0/Demos/Delphi.Net/DBWeb/WebFilter/WebForm1.pas Line: 290 Stack trace: [BdpException:
Connection open failed. unavailable database] Borland.Data.Provider.BdpDataAdapter.e()
Borland.Data.Provider.BdpDataAdapter.EndInit() WebForm1.TWebForm1.InitializeComponent() in G:/Program
Files/Borland/BDS/3.0/Demos/Delphi.Net/DBWeb/WebFilter/WebForm1.pas:290 WebForm1.TWebForm1.OnInit(EventArgs e) in
G:/Program Files/Borland/BDS/3.0/Demos/Delphi.Net/DBWeb/WebFilter/WebForm1.pas:344
System.Web.UI.Control.InitRecursive(Control namingContainer) System.Web.UI.Page.ProcessRequestMain()
-------------------------------------------------- ------------------------------
Version information: Microsoft .NET Framework Version: 1.1.4322.573; asp.net Version: 1.1.4322.573 If BdpDataAdapter1's Active
When the property is set to false, the following error occurs:
Server error in the "/DBWebFilterSample" application.
-------------------------------------------------- ------------------------------
The input string is incorrect.
Description: An unhandled exception occurred during the execution of the current web request. Please check the stack trace information for details about the error and where the error was caused in the code.
Exception details: System.FormatException: The input string is incorrectly formatted. Source error: Line 325: else Line 326: sCurrentFilter :=
Convert.ToString(o); Line 327: StartCustId := Convert.ToInt16(ListBox1.SelectedValue); Line 328: EndCustId :=
Convert.ToInt16(ListBox2.SelectedValue);Line 329: if StartCustId < EndCustId then
Source file: G:/Program Files/Borland/BDS/3.0/Demos/Delphi.Net/DBWeb/WebFilter/WebForm1.pas Line: 327 Stack trace: [FormatException:
The input string is incorrect. ] 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
Files/Borland/BDS/3.0/Demos/Delphi.Net/DBWeb/WebFilter/WebForm1.pas:327 System.Web.UI.Control.OnLoad(EventArgs e)
System.Web.UI.Control.LoadRecursive() System.Web.UI.Page.ProcessRequestMain()
-------------------------------------------------- ------------------------------
Version information: Microsoft .NET Framework version: 1.1.4322.573; ASP.NET version: 1.1.4322.573
Since my test focus is to use delphi2005 to implement web query, I slightly modified the above minor errors, and there was no error in the compilation and operation, but no data was displayed. In order to let it display data, the author
Add a button to the webform1 design form, and add the following code to the button event:
if not BdpDataAdapter1.Active
thenBdpDataAdapter1.Active:=true;
When you click this button when you compile and run, the following error occurs:
Server error in the "/DBWebFilterSample" application.
-------------------------------------------------- ------------------------------
Connection open failed. unavailable database
Description: An unhandled exception occurred during the execution of the current web request. Please check the stack trace information for details about the error and where the error was caused in the code.
Exception details:
Borland.Data.Common.BdpException: Connection open failed. unavailable database source error: Line 301:
if not BdpDataAdapter1.Active then line 303:
BdpDataAdapter1.Active:=true;//The line 304 occurred in this sentence:
end;
Source file: G:/Program
Files/Borland/BDS/3.0/Demos/Delphi.Net/DBWeb/WebFilter/WebForm1.pas Line: 303
Stack trace: [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
Files/Borland/BDS/3.0/Demos/Delphi.Net/DBWeb/WebFilter/WebForm1.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()
-------------------------------------------------- ------------------------------
Version information: Microsoft .NET Framework version: 1.1.4322.573; ASP.NET version: 1.1.4322.573
Carefully check the help file. The Active property of BdpDataAdapter1 needs to be set to true, but this is not possible after setting it. There must be a problem with the database connection, but the data is tested in the design state
There is no problem with the library connection, so I added the button event to the database connection all properties, compile and run, click, and the failure remains. Check the help file carefully, and the following contents are included:
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 Files/Borland/Interbase/Examples/Database/employee.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.
So set the ConnectionString property of BdpConnection1 to databases=localhost:g:/Program
Files/Borland/Interbase/Examples/Database/employee.gdb;assembly=Borland.Data.Interbase,Version=2.0.0.0,Culture=neutral,Public
KeyToken=91d62ebb5b0d1b1b;vendorclient=gds32.dll;provider=Interbase;username=sysdba;password=masterkey
Set the Active property of BdpDataAdapter1 to true
Remove the added buttons and their code, compile and run again, everything is normal.