|
|
#1 |
|
Addicted Member
Join Date: May 06
Posts: 178
![]() |
Hi;
I try to get informations from an Access DB. There is tabcontrol. There are some tabstops. If you enter a tabstop it tries to update data in Datagridview. But at the first time you enter to tabstop it normally takes data from database. If you try to take data for a second time you need to do this: VB Code:
and in this function I get the error, which is written in the title: VB Code:
__________________
Dim Me As Coder |
|
|
|
|
|
#2 |
|
Snarky...
Join Date: May 02
Posts: 15,476
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Re: [2005] "A DataTable named 'Stok' already belongs to this DataSet."
1) Are you trying to use ADO or ADO.NET? Your code is using both. Pick one or the other and stick to it.
2) Yes, you are clearing the TABLES.... not the dataset.... big difference. Instead of using .CLEAR, check to see if the table exists in the Dataset first, then remove the table from the collection. Then you can fill it and add it back it..... -tg
__________________
* I don't respond to private requests for help. It's not conducive to the general learning of others.-I also subscribe to all threads I participate, so there's no need to pm when there's an update.* * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft * * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? * On Error Resume Next is error ignoring, not error handling(tm). * Use Offensive Programming, not Defensive Programming. "There is a major problem with your code, and VB wants to tell you what it is.. but you have decided to put your fingers in your ears and shout 'I'm not listening!'" - si_the_geek on using OERN MVP '06-'10 |
|
|
|
|
|
#3 |
|
Addicted Member
Join Date: May 06
Posts: 178
![]() |
Re: [2005] "A DataTable named 'Stok' already belongs to this DataSet."
for 1) Hmm but it works good exccept this
for 2) it seems that it doesnt exists after clear function but it gives the error
__________________
Dim Me As Coder |
|
|
|
|
|
#4 |
|
.NUT
Join Date: May 05
Location: Sydney, Australia
Posts: 61,544
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Re: [2005] "A DataTable named 'Stok' already belongs to this DataSet."
My question is "why remove the table in the first place". If you just call the Fill method of a DataAdapter and pass a DataSet and a table name then it will populate a DataTable with that name, creating it if it doesn't exist. If you want to get rid of existing data then just clear the contents of the table:
VB Code:
__________________
![]() 2007-2010 Why is my data not saved to my database? | Communicating between multiple forms | MSDN Data Walkthroughs MSDN "How Do I?" Videos: VB | C# VBForums Database Development FAQ My CodeBank Submissions: VB (Nullable Data Extensions *NEW*) (Serial Code TextBox *NEW*) | C# (ForumAccount has translated some of my VB submissions to C#) My Blog: Defining and Raising Custom Events | Using Parameters in ADO.NET | Keyboard Events *NEW* |
|
|
|
|
|
#5 |
|
Addicted Member
Join Date: May 06
Posts: 178
![]() |
Re: [2005] "A DataTable named 'Stok' already belongs to this DataSet."
Thanks again... it worked great jmchil
__________________
Dim Me As Coder |
|
|
|
![]() |
|
||||||
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|