From: John T. <jr...@gt...> - 2003-03-06 19:27:59
|
Hi, Seem to have a problem getting the value back from a stored proc. My example passes a param and expects a return value. var Adapter : FbDataAdapter ; command: FbCommand; connection: FBConnection; transaction: FBTransaction; ds: DataSet; builder:FbCommandBuilder; NEWROW:DATAROW; parameterHits: FBParameter; parameterHits2: FBParameter; procedure Page_Load2(Sender: System.Object; E: EventArgs); begin connection:=FBConnection.create(MyConnectionString); connection.open; transaction:=Connection.BeginTransaction; Command := FbCommand.Create('EXECUTE PROCEDURE CODE_SS', Connection, transaction); Command.CommandType := CommandType.StoredProcedure; parameterHits := FbParameter.Create('P1', FbType.Integer); parameterHits.VALUE:='22'; parameterHits.Direction := ParameterDirection.Input;// output; Command.Parameters.Add(parameterHits); lblHits.Text:='Total: ' + parameterHits.Value.ToString; // lets get the results parameterHits2 := FbParameter.Create('CTI', FbType.VARCHAR); parameterHits2.Direction := ParameterDirection.output; Command.Parameters.Add(parameterHits2); lblHits2.Text:= string(parameterHits2.Value).ToString; // this produces the following error: Server Error in '/' Application. ---------------------------------------------------------------------------- ---- Object reference not set to an instance of an object. 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: System.NullReferenceException: Object reference not set to an instance of an object. Source Error: Line 149: // Command.ExecuteNonQuery; Line 150: Line 151: lblHits2.Text:= parameterHits2.Value.ToString; Line 152: Line 153: { Source File: D:\WINNT\Microsoft.NET\Framework\v1.0.3705\Temporary ASP.NET Files\root\0950ba24\bc3a41b5\rb2ld54f.0.pas Line: 151 Stack Trace: [NullReferenceException: Object reference not set to an instance of an object.] ASP.dategrid_fb_add4_SP_aspx.Page_Load2(Object Sender, EventArgs E) in D:\WINNT\Microsoft.NET\Framework\v1.0.3705\Temporary ASP.NET Files\root\0950ba24\bc3a41b5\rb2ld54f.0.pas:151 System.Web.UI.WebControls.Button.OnClick(EventArgs e) +83 System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePo stBackEvent(String eventArgument) +57 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33 System.Web.UI.Page.ProcessRequestMain() +1263 ---------------------------------------------------------------------------- ---- Version Information: Microsoft .NET Framework Version:1.0.3705.288; ASP.NET Version:1.0.3705.288 |