EStallworth
Well-known member
I am currently developing an application that queries an informix database. After I have loaded the dataset with the information I need, I am attempting to pick out a certain row and move it to another dataset in order to set up a binding for a textbox. Only problem is that I receive an error message saying the row is already contained in another dataset. I am moving the particular row from one to the other because I do not write queries that well and cannot pick out the individual row that I need the first time around. I load up all of the transactions of a certain account and I sort it according to the most recent transaction(based on date). Why is it that you cannot bind an object to a dataset that contains a copy of another dataset's row?
VB.NET:
[SIZE=2][COLOR=#0000ff]Try[/COLOR][/SIZE]
[SIZE=2]InformixDataSet11.Clear()[/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] ODBCAdapt [/SIZE][SIZE=2][COLOR=#0000ff]As [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] System.Data.Odbc.OdbcDataAdapter[/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] connection [/SIZE][SIZE=2][COLOR=#0000ff]As [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] Odbc.OdbcConnection([/SIZE][SIZE=2][COLOR=#800000]""[/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] selectcommand [/SIZE][SIZE=2][COLOR=#0000ff]As [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] Odbc.OdbcCommand([/SIZE][SIZE=2][COLOR=#800000]"Select trans_no, trans_date, check_no, trans_amt, vend_no FROM informix.transact WHERE vend_no = ? ORDER BY trans_date DESC"[/COLOR][/SIZE][SIZE=2], connection)[/SIZE]
[SIZE=2]selectcommand.Parameters.Add([/SIZE][SIZE=2][COLOR=#800000]"?"[/COLOR][/SIZE][SIZE=2], Odbc.OdbcType.NVarChar, 10, [/SIZE][SIZE=2][COLOR=#800000]"vendor_no"[/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] param [/SIZE][SIZE=2][COLOR=#0000ff]As [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2] = ComboBox1.Text.Remove(2, 1)[/SIZE]
[SIZE=2]selectcommand.Parameters([/SIZE][SIZE=2][COLOR=#800000]"?"[/COLOR][/SIZE][SIZE=2]).Value = param.Remove(5, 1)[/SIZE]
[SIZE=2]ODBCAdapt.SelectCommand = selectcommand[/SIZE]
[SIZE=2]ODBCAdapt.Fill(InformixDataSet11)[/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] foundrow [/SIZE][SIZE=2][COLOR=#0000ff]As [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] System.Data.DataTable[/SIZE]
[SIZE=2]foundrow.Rows.Add(InformixDataSet11.Table.Rows.Item(1))[/SIZE]
[SIZE=2]checkamttxt.DataBindings.Add([/SIZE][SIZE=2][COLOR=#800000]"Text"[/COLOR][/SIZE][SIZE=2], foundrow, [/SIZE][SIZE=2][COLOR=#800000]"foundrow.trans_amt"[/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2][COLOR=#0000ff]Catch[/COLOR][/SIZE][SIZE=2] ex [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] Exception[/SIZE]
[SIZE=2] MessageBox.Show(ex.Message)[/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Try[/COLOR][/SIZE]