473,387 Members | 1,606 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,387 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 4762

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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.