473,399 Members | 4,177 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,399 software developers and data experts.

Getting duplicate column error when the table is disposed in the d

I have a dataset containing a table as a data source for a list box in the
windows application depending on which radio button the user selects. The
table is disposed when the user clicks on other radio button.

I'm getting an error message that a column that I added previously alreday
exists in the dataset. Each table that I add to the dataset according to
which radio button is selected is disposed when it's de-selected. Why does
the system still thinks that the column is still there? Below is the code
for this section. Thanks for any help in advance, Alpha

private void radioPayPlan_CheckedChanged(object sender, System.EventArgs e)
{
try
{
if (radioPayPlan.Checked == true)
{
//Setup the PaySource in listbox
cmdLocal.CommandText = "select sID, scode, sname from tblsource" ;
saLocal.Fill(dsLocal,"source");

drv = (DataRowView) BindingContext[dsLocal.Tables["source"]].Current;
dsLocal.Tables["source"].AcceptChanges();
//Create new column
DataColumn sc = new
DataColumn("ScodeName",Type.GetType("System.String "));
sc.Expression = "iif(len(scode) > 0,scode + ': ' + sname,sname)";
dsLocal.Tables["source"].Columns.Add(sc);
//this.lstSelections.SelectedIndex = 1;

dvSource = new
DataView(dsLocal.Tables["source"],"","sname",DataViewRowState.CurrentRows);
this.lstSelections.DataSource = dvSource;
lstSelections.DisplayMember = "ScodeName";
lstSelections.ValueMember = "sID";
}
else
{
dsLocal.Tables["source"].Clear();
dsLocal.Tables["source"].Dispose();
dvSource.Dispose();

}
}
catch(Exception my_e)
{
MessageBox.Show("The system encountered an error loading listing
data:\n" + my_e.ToString());
}

}

Nov 17 '05 #1
0 1317

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

Similar topics

4
by: Doug Estep | last post by:
Below is a sample of my XML… <MetaData> <Table name="mytable"> <PrimaryKey name="pk"><Column name="mycolumn"/></PrimaryKey> </Table> </MetaData> <Sequencer> <Table name="mytable">
2
by: Richard | last post by:
Hi Everyone, I have a table in which their is record which is exactly same. I want to delete all the duplicate keeping ony 1 record in a table. Example Table A Empid currentmonth ...
2
by: Brad Allison | last post by:
I have created a short routine to read certain data from an AS400 and put it into a small table stored in Access (I know not the best data store, but it is what we have for now). Anyway, some of...
1
by: Andy L | last post by:
I have two identical databases running on two separate servers. I want to add a column to the following table: classified_cats { acid , name , parent } Running ALTER TABLE `classified_cats`...
2
by: mivey4 | last post by:
Okay I have 2 tables: Table A - holds a list of new hardware serial numbers and their corresponding model (no constraints or indexes) Table B - holds a distinct list of current serial numbers...
10
by: Rahul Babbar | last post by:
Hi, I am getting the following error, while executing the simple insert script on a few tables. INSERT INTO <table_name>(<col1>) VALUES (1); DB2 SQL error: SQLCODE: -440, SQLSTATE: 42884,...
4
by: ramdil | last post by:
Hi All I have table and it have around 90000 records.Its primary key is autonumber field and it has also have date column and name, then some other columns Now i have problem with the table,as my...
2
dlite922
by: dlite922 | last post by:
I have a permission table that gives a userID permission to a module and the any actions within that module. What I want to do is duplicate his permissions to another user. Permission table...
1
watertraveller
by: watertraveller | last post by:
Hi all. My ultimate goal is to return two columns, where no single value appears anywhere twice. This means that not only do I want to check that nothing from column A appears in column B and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.