473,221 Members | 1,751 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,221 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 4742

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Me | last post by:
Hi Folks I keep recieving the following error message when i try to bind a combobox to the value that is in a textbox. the application crashes on the following line... Me.CBoxTitle.SelectedItem...
4
by: prasad | last post by:
I am getting sql error during binding a program which access a temporary table. The temporary table declaration and access methods are given below. EXEC SQL DECLARE GLOBAL TEMPORARY TABLE TEM88...
1
by: VB Programmer | last post by:
I went to a few ASP.NET websites today. For some aspx pages I get this error (too consistently, which is why I think it's my PC): Server Error in '/CuteEditorTest' Application....
1
by: Dotnet Gruven | last post by:
I've posted this in the adonet group, however it was suggested I might have better luck here.... ============================================================= I'm trying to use a typed dataset and...
9
by: Timm | last post by:
I have an ASP.NET 2.0 page with two DropDownLists. I am using declarative data binding wherever possible and trying to minimize the use of code. The list of values in DropDownList DDL2 should be...
4
by: glebur | last post by:
Hi, I'm trying to create a web service client in C# but I get stuck at one of the first steps. When adding a Web reference to the Visual Studio project; I get this error (this is a translation,...
0
by: =?Utf-8?B?RGVuaXMgU29oZXQ=?= | last post by:
Hi all, I've created a new project to test ObjectDataSource component. I've just added a new objectdatasource, configured it (linked to a table) etc ... It works fine on localhost, i can...
3
by: Trez | last post by:
Hey guys, Am new at using ASP.Net. am having some problems updating my SQL DB. whenever i try i get this Error. Can someone help me? Incorrect syntax near 'nvarchar'. Description: An unhandled...
0
by: santycalde | last post by:
Hi!! I am executing a call to a webservice with SOAP and the following mistake takes place: The XML of the wsdl is: <?xml version="1.0" encoding="UTF-8" ?> - <wsdl:definitions...
0
by: Cirene | last post by:
Using Visual Studio I created a DataSet using the GUI (XSD file). Trying to use a tiered methodology I called the functions from my BLL. Namespace Zzz.BusinessLogicLayer #Region "DAL Access"...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

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.