472,145 Members | 1,415 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,145 software developers and data experts.

Fix for error during Binding...Parameter name: '-2147483550' is not a valid value for 'index'.

Essentially, InsertAT is broken!

For the past couple of hours, I've been getting this "Parameter name:
'-2147483550' is not a valid value for 'index'." error.
Apparently, its caused by having manually inserted a row in the table
bound to the Combo box. The InsertAt Method of adding a row just does
not work.

Hope this helps anyone with this problem.
john
' first, build the row you want to manually add to your Combo,
using this method. in our case we needed a row with a NULL value, so
NULL values in the DB can be bound to the Combo.
ds.Tables.Add("Show")
ds.Tables("show").Columns.Add("ShowName")
ds.Tables("show").Columns.Add("ShowID")
Dim row As DataRow
row = ds.Tables("Show").NewRow
row("ShowName") = ""
row("ShowID") = DBNull.Value
ds.Tables("Show").Rows.Add(row)

' now add in the rest of the rows from the lookup table.
Dim cmd As SqlDataAdapter = New
SqlDataAdapter("f_TABill_GetRecentShowNames", cn1)
With cmd.SelectCommand
.Parameters.Add(New SqlClient.SqlParameter("@DaysToGet",
nDaysToGet))
.Parameters.Add(New
SqlClient.SqlParameter("@GetThisPUShowIDToo", GetThisPUShowIDToo))
.Parameters.Add(New
SqlClient.SqlParameter("@GetThisDELShowIDToo", GetThisDELShowIDToo))
.CommandType = CommandType.StoredProcedure
End With

cmd.Fill(dsShows, "show")
' following method for adding a row to the DS DOES NOT WORK!!!!!!!!
' INTERNALLY, IT MUST BE SCREWING UP THE DATA TABLE BECAUSE THE BINDING
MECHANISM GOES NUTS
' WHEN TRYING TO BIND TO THE THIS MANUALLY INSERTED ROW.
' Dim dr As DataRow
' dr = dsShows.Tables("show").NewRow()
' dr.Item("ShowID") = DBNull.Value
' dr.Item("ShowName") = ""

' dsShows.Tables("show").Rows.InsertAt(dr, 0) << tried
this, got following error
Specified argument was out of the range of valid values.

Parameter name: '-2147483550' is not a valid value for 'index'.
Error ID: EJB0501281707 ComboBox=cboPUShow
Version: 10.0.0.80
Source: System
TargetSite: Void SetValue(System.Object, System.Object)
Stack: at
System.ComponentModel.ReflectPropertyDescriptor.Se tValue(Object
component, Object value)
' dsShows.Tables("show").Rows.InsertAt(dr, 6) << tried
this too, got a different error below
DataBinding could not find a row in the list that is suitable for all
bindings
Error ID: EJS0503151000
Version: 10.0.0.80
Source: System.Windows.Forms
TargetSite: Void FindGoodRow()
Stack: at System.Windows.Forms.CurrencyManager.FindGoodRow()
With cboPUShow
.DisplayMember = "ShowName" ' Case Sensitive or
you'll get weird stuff in the dropdown.
.ValueMember = "ShowID" ' Case Sensitive or
you'll never debug this!
.DataSource = New DataView(dsShows.Tables("show"))
.SelectedIndex = -1 ' this clears the
current index, but does not trigger _Validating.
.SelectedIndex = -1 ' this clears the
current index, but does not trigger _Validating.
End With
Ronald wrote:
Hi,

I have this binding exception I can't figure out.
What I want is to show a list of parent records in a drop combo, and add a single line, like "Not used" item.
Summary:
Adding a row to the top of a filled table, using "table.Rows.InsertAt(row, 0);" and binding a combobox's SelectedValue throws an exception.
If I use the same InsertAt method, but add the row at another position, it works fine.
Explanation:
I use a DataTable filled with the SQL query result. The table has 2 columns: An columnID (int) and a columnName (string) column.
the columnID is actually the primary key field of the file.

I bind a class property (int) to the value (this refers to a ComboBox derived class instance)
this.DataSource = <My DataTable, columns[0] = int, columns[1] = string> this.DisplayMember = columnName
this.ValueMember = columnID

this.DataBindings.Add("SelectedValue", businessObject, "Prop");

and businessObject has an int property Prop { get; set; }.

Now what works is adding the "Not used" item like this:

DataRow row = table.NewRow();
row[0] = (int)(-1);
row[1] = (string)"Not used";
table.Rows.InsertAt(row, 1); // Add at position 1, that's not the top !!! table.AcceptChanges();

what does *not* work is:
DataRow row = table.NewRow();
row[0] = (int)(-1);
row[1] = (string)"Not used";
table.Rows.InsertAt(row, 0); // Add at position 0, that the top and throws exception table.AcceptChanges();

Any ideas?
TIA
Ronald

exceptions is like this:

System.ArgumentOutOfRangeException: Het opgegeven argument ligt buiten het bereik van geldige waarden. Parameternaam: -2147483648 is geen geldige waarde voor index.
at System.ComponentModel.ReflectPropertyDescriptor.Se tValue(Object component, Object value) at System.Windows.Forms.Binding.SetPropValue(Object value)
at System.Windows.Forms.Binding.PushData()
at System.Windows.Forms.Binding.UpdateIsBinding()
at System.Windows.Forms.Binding.CheckBinding()
at System.Windows.Forms.Binding.SetListManager(Bindin gManagerBase bindingManagerBase) at System.Windows.Forms.ListManagerBindingsCollection .AddCore(Binding
dataBinding) at System.Windows.Forms.BindingsCollection.Add(Bindin g binding)
at System.Windows.Forms.BindingContext.UpdateBinding( BindingContext
newBindingContext, Binding binding) at System.Windows.Forms.Binding.SetControl(Control value)
at System.Windows.Forms.ControlBindingsCollection.Add Core(Binding dataBinding) at System.Windows.Forms.ControlBindingsCollection.Add (Binding binding) at System.Windows.Forms.ControlBindingsCollection.Add (String propertyName, Object dataSource, String dataMember)
----> This is my call:
at Compad.Forms.ComboBox.Bind(IBusinessObject

primaryBusinessObject)

Nov 21 '05 #1
0 4608

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Me | last post: by
1 post views Thread by VB Programmer | last post: by
reply views Thread by =?Utf-8?B?RGVuaXMgU29oZXQ=?= | last post: by
3 posts views Thread by Trez | last post: by
reply views Thread by santycalde | last post: by
reply views Thread by Saiars | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.