From: Henning S. <hsw...@ms...> - 2004-10-08 23:49:09
|
<html><div style='background-color:'><DIV class=RTE> <P>Hello,</P> <P>I'm getting an error when I try to update an record with firebird.net driver.</P> <P>the following procedure ends in an error:</P> <P><BR>procedure TADBildePrisMatrise.Dg1_UpdateCommand(source: System.Object; e: System.Web.UI.WebControls.DataGridCommandEventArgs);<BR>var<BR> id: string;<BR> fbcon:fbconnection;<BR> fbcom:fbcommand;<BR>begin<BR> id := dg1.DataKeys[e.Item.ItemIndex].ToString;<BR> fbcon := fbconnection.create(getconnectionstring);</P> <P> fbcom := fbcommand.Create;<BR> fbcom.Connection := fbcon;<BR> fbcom.CommandText := ('UPDATE BILDEPRISMATRISE SET FELTNAVN = @SFELTNAVN, VERDI = @SVERDI, REFID1 = @SREFID1, REFID2 = @SREFID2 WHERE IDPRISMATRISE = @SIDL');<BR> fbcom.Parameters.Add('SFELTNAVN',(e.Item.Cells[2].Controls[0] as TextBox).Text);<BR> fbcom.Parameters.Add('SVERDI',(e.Item.Cells[3].Controls[0] as TextBox).Text);<BR> fbcom.Parameters.Add('SREFID1',(e.Item.Cells[4].Controls[0] as TextBox).Text);<BR> fbcom.Parameters.Add('SREFID2',(e.Item.Cells[5].Controls[0] as TextBox).Text);<BR> fbcom.Parameters.Add('SID',id);</P> <P> fbcon.Open;<BR> try<BR> fbcom.ExecuteNonQuery;<BR> finally<BR> fbcon.Close;<BR> end;<BR>end;<BR><BR>If I change the sql command to this: </P> <P> (*<BR> fbcom := fbcommand.Create(swSqlFB(format('UPDATE BILDEPRISMATRISE SET FELTNAVN = %s, VERDI = %s, REFID1 = %s, REFID2 = %s WHERE IDPRISMATRISE = %s',<BR> [QuotedStr((e.Item.Cells[2].Controls[0] as TextBox).Text),<BR> QuotedStr((e.Item.Cells[3].Controls[0] as TextBox).Text),<BR> QuotedStr((e.Item.Cells[4].Controls[0] as TextBox).Text),<BR> QuotedStr((e.Item.Cells[5].Controls[0] as TextBox).Text),<BR> QuotedStr(id)])),fbcon);<BR> *)<BR> all works fine.</P> <P>This is the error message I'm getting:</P><FONT size=2> <P>---> System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index</P> <P>at System.Collections.ArrayList.get_Item(Int32 index)<BR>at System.Collections.SyncArrayList.get_Item(Int32 index)<BR>at FirebirdSql.Data.Firebird.FbParameterCollection.get_Item(Int32 parameterIndex)<BR>at FirebirdSql.Data.Firebird.FbParameterCollection.get_Item(String parameterName)<BR>at FirebirdSql.Data.Firebird.FbCommand.buildNamedParametersDescriptor(Int16 count)<BR>at FirebirdSql.Data.Firebird.FbCommand.buildParametersDescriptor()<BR>at FirebirdSql.Data.Firebird.FbCommand.InternalPrepare()<BR>at FirebirdSql.Data.Firebird.FbCommand.executeCommand(CommandBehavior behavior, Boolean split)<BR>at FirebirdSql.Data.Firebird.FbCommand.ExecuteNonQuery()<BR>at ADBildePrisMatrise.TADBildePrisMatrise.Dg1_UpdateCommand(Object source, DataGridCommandEventArgs e) in Admin\Bildebase\ADBildePrisMatrise.pas:line 111<BR>at System.Web.UI.WebControls.DataGrid.OnUpdateCommand(DataGridCommandEventArgs e)</P> <P>line 111 is: fbcom.ExecuteNonQuery;</P> <P>Software</P> <P>Firebird.net v.1.6.2<BR>Firebird server 1.5.0<BR>.Net Framework 1.1, no sp.<BR>Delphi 8 sp2</P> <P> </P></FONT></DIV></div></html> |