delphi8.0中的开发asp.net中的数据库中BdpDataAdapter1与dataset连接问题(100分)

  • 主题发起人 主题发起人 jyyousr
  • 开始时间 开始时间
J

jyyousr

Unregistered / Unconfirmed
GUEST, unregistred user!
关于数据连接问题在winform中的没问题,在开发asp.net就总是通不过,不知是什么原因,现将程序代码为错误代码提供如下,请各位指教!
错误提示代码为:
Server Error in '/WebApplication2' Application.
--------------------------------------------------------------------------------
Connection open failed. SQL State: 42000, SQL Error Code: 18456
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: Borland.Data.Common.BdpException: Connection open failed. SQL State: 42000, SQL Error Code: 18456
Source Error:

Line 189: Self.dataSet1.Locale := System.Globalization.CultureInfo.Create('zh-CN');
Line 190: Include(Self.Load, Self.Page_Load);
Line 191: (System.ComponentModel.ISupportInitialize(Self.BdpDataAdapter1)).EndInit;
Line 192: (System.ComponentModel.ISupportInitialize(Self.dataSet1)).EndInit;
Line 193:end;

Source File: c:/inetpub/wwwroot/WebApplication2/WebForm1.pas Line: 191
Stack Trace:

[BdpException: Connection open failed. SQL State: 42000, SQL Error Code: 18456
]
Borland.Data.Provider.BdpDataAdapter.e() +656
Borland.Data.Provider.BdpDataAdapter.EndInit() +60
WebForm1.TWebForm1.InitializeComponent() in c:/inetpub/wwwroot/WebApplication2/WebForm1.pas:191
WebForm1.TWebForm1.OnInit(EventArgs e) in c:/inetpub/wwwroot/WebApplication2/WebForm1.pas:206
System.Web.UI.Control.InitRecursive(Control namingContainer) +240
System.Web.UI.Page.ProcessRequestMain() +174


--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.573;
ASP.NET Version:1.1.4322.573
程序代码为:
unit WebForm1;
interface
uses
System.Collections, System.ComponentModel,
System.Data, System.Drawing, System.Web, System.Web.SessionState,
System.Web.UI, System.Web.UI.WebControls, System.Web.UI.HtmlControls,
System.Globalization, Borland.Data.Provider, Borland.Data.Common;
type
TWebForm1 = class(System.Web.UI.Page)
{$REGION 'Designer Managed Code'}
strict private
procedure InitializeComponent;
procedure Button1_Click(sender: System.Object;
e: System.EventArgs);
{$ENDREGION}
strict private
procedure Page_Load(sender: System.Object;
e: System.EventArgs);
strict protected
Button1: System.Web.UI.WebControls.Button;
BdpConnection1: Borland.Data.Provider.BdpConnection;
BdpDataAdapter1: Borland.Data.Provider.BdpDataAdapter;
bdpSelectCommand1: Borland.Data.Provider.BdpCommand;
bdpInsertCommand1: Borland.Data.Provider.BdpCommand;
bdpUpdateCommand1: Borland.Data.Provider.BdpCommand;
bdpDeleteCommand1: Borland.Data.Provider.BdpCommand;
dataSet1: System.Data.DataSet;
procedure OnInit(e: EventArgs);
override;
private
{ Private Declarations }
public
{ Public Declarations }
end;

implementation
{$REGION 'Designer Managed Code'}
/// <summary>
/// Required method for Designer support --do
not modify
/// the contents of this method with the code editor.
/// </summary>
procedure TWebForm1.InitializeComponent;
begin
Self.BdpConnection1 := Borland.Data.Provider.BdpConnection.Create;
Self.BdpDataAdapter1 := Borland.Data.Provider.BdpDataAdapter.Create;
Self.bdpSelectCommand1 := Borland.Data.Provider.BdpCommand.Create;
Self.bdpInsertCommand1 := Borland.Data.Provider.BdpCommand.Create;
Self.bdpUpdateCommand1 := Borland.Data.Provider.BdpCommand.Create;
Self.bdpDeleteCommand1 := Borland.Data.Provider.BdpCommand.Create;
Self.dataSet1 := System.Data.DataSet.Create;
(System.ComponentModel.ISupportInitialize(Self.BdpDataAdapter1)).begin
Init;
(System.ComponentModel.ISupportInitialize(Self.dataSet1)).begin
Init;
Include(Self.Button1.Click, Self.Button1_Click);
//
// BdpConnection1
//
Self.BdpConnection1.ConnectionOptions := 'transaction isolation=ReadCommitted;blob size=1024';
Self.BdpConnection1.ConnectionString := 'assembly=Borland.Data.Mssql, Version=1.5.0.0, Culture=neutral, PublicKeyToken=9'+
'1d62ebb5b0d1b1b;vendorclient=sqloledb.dll;osauthen
tication=True;database=North'+
'wind;username=myuser;hostname=;password=mypass;provider=MSSQL';
//
// BdpDataAdapter1
//
Self.BdpDataAdapter1.Active := False;
Self.BdpDataAdapter1.DataSet := Self.dataSet1;
Self.BdpDataAdapter1.DataTable := nil;
Self.BdpDataAdapter1.DeleteCommand := Self.bdpDeleteCommand1;
Self.BdpDataAdapter1.InsertCommand := Self.bdpInsertCommand1;
Self.BdpDataAdapter1.SelectCommand := Self.bdpSelectCommand1;
Self.BdpDataAdapter1.StartRecord := 0;
Self.BdpDataAdapter1.UpdateCommand := Self.bdpUpdateCommand1;
//
// bdpSelectCommand1
//
Self.bdpSelectCommand1.CommandOptions := nil;
Self.bdpSelectCommand1.CommandText := 'SELECT EmployeeID, LastName, FirstName, City FROM dbo.Employees';
Self.bdpSelectCommand1.CommandType := System.Data.CommandType.Text;
Self.bdpSelectCommand1.Connection := Self.BdpConnection1;
Self.bdpSelectCommand1.ParameterCount := (SmallInt(0));
Self.bdpSelectCommand1.SchemaName := nil;
Self.bdpSelectCommand1.Transaction := nil;
Self.bdpSelectCommand1.UpdatedRowSource := System.Data.UpdateRowSource.None;
//
// bdpInsertCommand1
//
Self.bdpInsertCommand1.CommandOptions := nil;
Self.bdpInsertCommand1.CommandText := 'INSERT INTO dbo.Employees (EmployeeID, LastName, FirstName, City ) VALUES ( ?, '+
'?, ?, ?)';
Self.bdpInsertCommand1.CommandType := System.Data.CommandType.Text;
Self.bdpInsertCommand1.Connection := Self.BdpConnection1;
Self.bdpInsertCommand1.ParameterCount := (SmallInt(4));
Self.bdpInsertCommand1.Parameters.Add(Borland.Data.Common.BdpParameter.Create('EmployeeID',
Borland.Data.Common.BdpType.Int32, Borland.Data.Common.BdpType.Unknown,
0, System.Data.ParameterDirection.Input, False, (Byte(10)), (Byte(0)),
10, 'EmployeeID', System.Data.DataRowVersion.Current, nil));
Self.bdpInsertCommand1.Parameters.Add(Borland.Data.Common.BdpParameter.Create('LastName',
Borland.Data.Common.BdpType.&String, Borland.Data.Common.BdpType.Unknown,
0, System.Data.ParameterDirection.Input, False, (Byte(0)), (Byte(0)),
0, 'LastName', System.Data.DataRowVersion.Current, nil));
Self.bdpInsertCommand1.Parameters.Add(Borland.Data.Common.BdpParameter.Create('FirstName',
Borland.Data.Common.BdpType.&String, Borland.Data.Common.BdpType.Unknown,
0, System.Data.ParameterDirection.Input, False, (Byte(0)), (Byte(0)),
0, 'FirstName', System.Data.DataRowVersion.Current, nil));
Self.bdpInsertCommand1.Parameters.Add(Borland.Data.Common.BdpParameter.Create('City',
Borland.Data.Common.BdpType.&String, Borland.Data.Common.BdpType.Unknown,
0, System.Data.ParameterDirection.Input, False, (Byte(0)), (Byte(0)),
0, 'City', System.Data.DataRowVersion.Current, nil));
Self.bdpInsertCommand1.SchemaName := nil;
Self.bdpInsertCommand1.Transaction := nil;
Self.bdpInsertCommand1.UpdatedRowSource := System.Data.UpdateRowSource.None;
//
// bdpUpdateCommand1
//
Self.bdpUpdateCommand1.CommandOptions := nil;
Self.bdpUpdateCommand1.CommandText := 'UPDATE dbo.Employees SET EmployeeID = ?, LastName = ?, FirstName = ?, City = ? '+
'WHERE EmployeeID = ? AND LastName = ? AND FirstName = ? AND City = ?';
Self.bdpUpdateCommand1.CommandType := System.Data.CommandType.Text;
Self.bdpUpdateCommand1.Connection := Self.BdpConnection1;
Self.bdpUpdateCommand1.ParameterCount := (SmallInt(8));
Self.bdpUpdateCommand1.Parameters.Add(Borland.Data.Common.BdpParameter.Create('EmployeeID',
Borland.Data.Common.BdpType.Int32, Borland.Data.Common.BdpType.Unknown,
0, System.Data.ParameterDirection.Input, False, (Byte(10)), (Byte(0)),
10, 'EmployeeID', System.Data.DataRowVersion.Current, nil));
Self.bdpUpdateCommand1.Parameters.Add(Borland.Data.Common.BdpParameter.Create('LastName',
Borland.Data.Common.BdpType.&String, Borland.Data.Common.BdpType.Unknown,
0, System.Data.ParameterDirection.Input, False, (Byte(0)), (Byte(0)),
0, 'LastName', System.Data.DataRowVersion.Current, nil));
Self.bdpUpdateCommand1.Parameters.Add(Borland.Data.Common.BdpParameter.Create('FirstName',
Borland.Data.Common.BdpType.&String, Borland.Data.Common.BdpType.Unknown,
0, System.Data.ParameterDirection.Input, False, (Byte(0)), (Byte(0)),
0, 'FirstName', System.Data.DataRowVersion.Current, nil));
Self.bdpUpdateCommand1.Parameters.Add(Borland.Data.Common.BdpParameter.Create('City',
Borland.Data.Common.BdpType.&String, Borland.Data.Common.BdpType.Unknown,
0, System.Data.ParameterDirection.Input, False, (Byte(0)), (Byte(0)),
0, 'City', System.Data.DataRowVersion.Current, nil));
Self.bdpUpdateCommand1.Parameters.Add(Borland.Data.Common.BdpParameter.Create('EmployeeIDOriginal',
Borland.Data.Common.BdpType.Int32, Borland.Data.Common.BdpType.Unknown,
0, System.Data.ParameterDirection.Input, False, (Byte(10)), (Byte(0)),
10, 'EmployeeID', System.Data.DataRowVersion.Original, nil));
Self.bdpUpdateCommand1.Parameters.Add(Borland.Data.Common.BdpParameter.Create('LastNameOriginal',
Borland.Data.Common.BdpType.&String, Borland.Data.Common.BdpType.Unknown,
0, System.Data.ParameterDirection.Input, False, (Byte(0)), (Byte(0)),
0, 'LastName', System.Data.DataRowVersion.Original, nil));
Self.bdpUpdateCommand1.Parameters.Add(Borland.Data.Common.BdpParameter.Create('FirstNameOriginal',
Borland.Data.Common.BdpType.&String, Borland.Data.Common.BdpType.Unknown,
0, System.Data.ParameterDirection.Input, False, (Byte(0)), (Byte(0)),
0, 'FirstName', System.Data.DataRowVersion.Original, nil));
Self.bdpUpdateCommand1.Parameters.Add(Borland.Data.Common.BdpParameter.Create('CityOriginal',
Borland.Data.Common.BdpType.&String, Borland.Data.Common.BdpType.Unknown,
0, System.Data.ParameterDirection.Input, False, (Byte(0)), (Byte(0)),
0, 'City', System.Data.DataRowVersion.Original, nil));
Self.bdpUpdateCommand1.SchemaName := nil;
Self.bdpUpdateCommand1.Transaction := nil;
Self.bdpUpdateCommand1.UpdatedRowSource := System.Data.UpdateRowSource.None;
//
// bdpDeleteCommand1
//
Self.bdpDeleteCommand1.CommandOptions := nil;
Self.bdpDeleteCommand1.CommandText := 'DELETE FROM dbo.Employees WHERE EmployeeID = ? AND LastName = ? AND FirstName ='+
' ? AND City = ?';
Self.bdpDeleteCommand1.CommandType := System.Data.CommandType.Text;
Self.bdpDeleteCommand1.Connection := Self.BdpConnection1;
Self.bdpDeleteCommand1.ParameterCount := (SmallInt(4));
Self.bdpDeleteCommand1.Parameters.Add(Borland.Data.Common.BdpParameter.Create('EmployeeIDOriginal',
Borland.Data.Common.BdpType.Int32, Borland.Data.Common.BdpType.Unknown,
0, System.Data.ParameterDirection.Input, False, (Byte(10)), (Byte(0)),
10, 'EmployeeID', System.Data.DataRowVersion.Original, nil));
Self.bdpDeleteCommand1.Parameters.Add(Borland.Data.Common.BdpParameter.Create('LastNameOriginal',
Borland.Data.Common.BdpType.&String, Borland.Data.Common.BdpType.Unknown,
0, System.Data.ParameterDirection.Input, False, (Byte(0)), (Byte(0)),
0, 'LastName', System.Data.DataRowVersion.Original, nil));
Self.bdpDeleteCommand1.Parameters.Add(Borland.Data.Common.BdpParameter.Create('FirstNameOriginal',
Borland.Data.Common.BdpType.&String, Borland.Data.Common.BdpType.Unknown,
0, System.Data.ParameterDirection.Input, False, (Byte(0)), (Byte(0)),
0, 'FirstName', System.Data.DataRowVersion.Original, nil));
Self.bdpDeleteCommand1.Parameters.Add(Borland.Data.Common.BdpParameter.Create('CityOriginal',
Borland.Data.Common.BdpType.&String, Borland.Data.Common.BdpType.Unknown,
0, System.Data.ParameterDirection.Input, False, (Byte(0)), (Byte(0)),
0, 'City', System.Data.DataRowVersion.Original, nil));
Self.bdpDeleteCommand1.SchemaName := nil;
Self.bdpDeleteCommand1.Transaction := nil;
Self.bdpDeleteCommand1.UpdatedRowSource := System.Data.UpdateRowSource.None;
//
// dataSet1
//
Self.dataSet1.DataSetName := 'NewDataSet';
Self.dataSet1.Locale := System.Globalization.CultureInfo.Create('zh-CN');
Include(Self.Load, Self.Page_Load);
(System.ComponentModel.ISupportInitialize(Self.BdpDataAdapter1)).EndInit;
(System.ComponentModel.ISupportInitialize(Self.dataSet1)).EndInit;
end;
{$ENDREGION}
procedure TWebForm1.Page_Load(sender: System.Object;
e: System.EventArgs);
begin
// TODO: Put user code to initialize the page here
end;

procedure TWebForm1.OnInit(e: EventArgs);
begin
//
// Required for Designer support
//
InitializeComponent;
inherited OnInit(e);
end;

procedure TWebForm1.Button1_Click(sender: System.Object;
e: System.EventArgs);
begin
button1.Text:='welcome you!';
end;

end.
 
后退
顶部