473,466 Members | 1,464 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

DataAdapter combining data in DataGridView Question

Hello All,

I'm stumped with this one. I have a Database table ("PROD") and I have set up 2 different opens for it. As you can see I alias two of the columns in
the first open.

I run OpenST(), load a combo box for date selection. I then close the connection, and remove the dt from the dataset. Now I run OpenST1() and I want
to get all the columns for those dates and items selected.

In my testing I put a datagridview on the form and assigned dtST as the datasource. What I got in the dgv to my surprise was: STdate, STItem, (the
aliased columns from the 1st open) AND all the columns from the second select.

The dgv combined the data from the 1st open (15 rows) and then 125 rows of data from the 2nd open. After the first open I tried various combinations
of:

cnST.Close()
cnST.Dispose()
ds.Tables.Remove(dtST)
daST.Dispose()
dtST.Dispose()
cmbST.Dispose() 'Command Builder

Why do I have data from both data adapters in my dgv?

Please shed some light on this.

Thanks,

Hexman

vb.net 2005, Access DB
************************************************** ****
Private Sub OpenST()
cnST = New OleDbConnection(...)

STQrySel = "Select DISTINCT PRDate as STDate, PRItem as STItem " & _
"FROM PROD " & _
"WHERE PRDate = ? " & _
"ORDER BY PRDate, PRItem ; "
STQryAdd = " ; "
STQryDel = " ; "
STQryUpd = " ; "
daST.SelectCommand = New OleDbCommand(STQrySel, cnST)
daST.SelectCommand.Parameters.Add("ProdDate", OleDbType.Date, 8)
daST.SelectCommand.Parameters("ProdDate").Value = SeekProdDate
daST.InsertCommand = New OleDbCommand(STQryAdd, cnST)
daST.DeleteCommand = New OleDbCommand(STQryDel, cnST)
daST.UpdateCommand = New OleDbCommand(STQryUpd, cnST)
STCount = daST.Fill(dtST)
ds.Tables.Add(dtST)
End Sub

Private Sub OpenST1()
cnST = New OleDbConnection(...)

STQrySel = "Select * " & _
"FROM PROD " & _
"WHERE PRDate = ? and PRItem = ? " & _
"ORDER BY PRDate, PRItem, PRProdCode ; "
STQryAdd = " ; "
STQryDel = " ; "
STQryUpd = " ; "
daST.SelectCommand = New OleDbCommand(STQrySel, cnST)
daST.SelectCommand.Parameters.Add("ProdDate", OleDbType.Date, 8)
daST.SelectCommand.Parameters.Add("ProdItem", OleDbType.VarChar, 3)
daST.SelectCommand.Parameters("ProdDate").Value = SeekProdDate
daST.SelectCommand.Parameters("ProdItem").Value = SeekProdItem
daST.InsertCommand = New OleDbCommand(STQryAdd, cnST)
daST.DeleteCommand = New OleDbCommand(STQryDel, cnST)
daST.UpdateCommand = New OleDbCommand(STQryUpd, cnST)
STCount = daST.Fill(dtST)
ds.Tables.Add(dtST)
End Sub
Nov 30 '06 #1
0 2126

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

Similar topics

2
by: hch | last post by:
dataAdapter.Update(data, "TableName") won’t work! I was about to deploy my first website on the Internet only to discover that the dataAdapter.Update() throws the Server Error in the third...
1
by: AKJTR | last post by:
i'm trying to save on calls back to the db by combining stored procs in one dataadapter. I know they work alone but when i combine the i get an error " Could not find stored procedure...
13
by: Doug Bell | last post by:
Hi, I thought I had this sorted this morning but it is still a problem. My application has a DataAccess Class. When it starts, it: Connects to a DB (OLE DB) If it connects it uses an...
8
by: Zorpiedoman | last post by:
I keep getting a concurrency exception the second time I make a change and attempt to update a dataadapter. It appears this is by design, so there must be something I can do to avoid it. ...
7
by: Max | last post by:
I've included the needed tables in the DataSource. Those tables that are bound to controls I can workwith. But how do you get access to the DataAdaptors that are not bound? me.Dataset1.table...
4
by: George | last post by:
Got a question about the side effect of DataAdapter.Update() and DataTable.GetChanges(). Say I set up a DataTable and a DataAdapter in a class. Delete (Not remove) a row in the data table and...
5
by: George | last post by:
I have set DataAdapter.AcceptChangesDuringUpdate = true; However, I find that I still need to call AcceptChanges on the associated DataTable, DataTable.AcceptChanges(); Has anyone...
2
by: Ivan | last post by:
I have a class Foo which have two property. I have a thread that do some process and update class Foo int B. I have a datagridview on main form. this datagridview data source to this class Foo and...
2
by: mdfayazi | last post by:
I am using dataadapter to Add,Update,Delete rows in a datagridview.Update and delete are working but while adding a rows the problem comes.When I add more than one row only first row values are...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...
1
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
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.