|
Hi,
You need to implment the parent-child relationship between the two tables to get the desired results. You may try the following code snippet:
---------------------------------------------------------------------------------------------------
BEGIN CODE
Dim dc As OleDbConnection
Dim connstr As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source = C:\Nwind.mdb;"
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim da As OleDbDataAdapter
Dim dt As DataTable
Dim dv As DataView
dc = New OleDbConnection(connstr)
da = New OleDbDataAdapter("Select * from Products", dc)
dt = New DataTable
da.Fill(dt)
dv = New DataView(dt)
Me.ListBox1.DataSource = dv
End Sub
Private Sub ListBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
Dim SupplierIDString = Me.C1Combo1.Columns("SupplierID").Text.ToString()
Dim da As OleDbDataAdapter
Dim dt As DataTable
Dim dv As DataView
dc = New OleDbConnection(connstr)
da = New OleDbDataAdapter("Select * from Supplier where SupplierID = '" + SupplierID+ "'", dc)
dt = New DataTable
da.Fill(dt)
dv = New DataView(dt)
Me.ListBox2.DataSource = dv
End Sub
END CODE
---------------------------------------------------------------------------------------------------
Hope this helps .
Regards,
John Adams
ComponentOne LLC
|
|
|
|
|
When I build my project, the debug version builds fine but the release version does not. No files appear in the Release folder within the bin directory, although, the file path set in the project settings is correct.
Any ideas?
|
|
|
|
|
Are you getting errors when you build in release mode? If so, what errors are you getting?
In the project settings, are you sure you are looking at the Release configuration when checking the build output path?
Without more info, it's hard to know what to suggest. But maybe this will help you think of another option to try.
|
|
|
|
|
Got it, thank you. Problem now sorted. Very silly mistake, so much so that it's embarrassing lol!
Thanks for the help
|
|
|
|
|
hi,
can anyone help me how to make this code little easier
Dim a1,a2,a3,a4,a5,a6,a7 as byte
a1 = Convert.ToByte(ListBox3.Items(0))
a2 = Convert.ToByte(ListBox3.Items(1))
a3 = Convert.ToByte(ListBox3.Items(2))
a4 = Convert.ToByte(ListBox3.Items(3))
a5 = Convert.ToByte(ListBox3.Items(4))
a6 = Convert.ToByte(ListBox3.Items(5))
a7 = Convert.ToByte(ListBox3.Items(6))
i'm now have confusing about array..
please anyone can guide me if have more than 7 statement..
|
|
|
|
|
Make it an array of 7 items, called a, then assign them in a loop.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Arrays are zero based, so the index gets different from your current names:
Dim a(6) as Byte
For i As Integer = 0 to 6
a(i) = Convert.ToByte(ListBox3.Items(i))
Next
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Yeah, I'd have done that, but I was pretty sure my VB would not compile...
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Christian Graus wrote: Yeah, I'd have done that, but I was pretty sure my VB would not compile...
Why do you think that?
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Because if I did it off the top of my head, I don't know VB that well. I am about to 5 you BTW, I can't believe how many good answers get 1 votes now.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
I Need to list all the domains and machine in the domains in the network in VB 2.0. does any one has the code
|
|
|
|
|
nitin_ion wrote: in VB 2.0
You've got to be joking right!
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Surely he means VB.NET v2. Right?
Steve Jowett
-------------------------
It is offen dangerous to try and see someone else's point of view, without proper training. Douglas Adams (Mostly Harmless)
|
|
|
|
|
I hope... else
Do until "Hell Freezes Over"
Debug.Print("Astonished")
Loop
Kazz
"Users are there to click on things, not think. Let the archs do the damn thinking."
|
|
|
|
|
or
Gosub hades
Hades:
No return
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Sample:
*************************************************
Dim MyCollect as Collection
Set MyCollect = new Collection
Dim Data as Integer
Data = 1
MyCollect.Add Data
Data = 2
MyCollect.Add Data
Data = 3
MyCollect.Add Data
Set MyCollect = Nothing
*************************************************
From the above sample, Collection class object has three item and without remove that item, i just set nothing. The "Set MyCollect = Nothing" statement really remove the item internally or we need to remove externally by iterate item and remove it.
The above sample item is integer data, but my case is that item is an object. So do i need to remove the item (object) from the collection then set nothing?
Sakthivel P.
|
|
|
|
|
It does what it says, sets th whole thing to nothing
Bob
Ashfield Consultants Ltd
|
|
|
|
|
Data is a value type, so you have three ints, not three references to one int. However, there are so many points of confusion here, that your best bet is to buy a book and read it.
Setting a collection to nothing does NOT do anything to the objects in it, it simply gets rid of the object which was maintaining references to the collection.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
That why i'm asking,
Set nothing to collection, it won't free or remove the items of the collection.
|
|
|
|
|
Well, if the collection is the only place a reference to the objects exists, then they are orphaned and will be GC eventually. But, if you have other references to them, then no
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
This collection only the reference to the object. so do i need to remove the item and delete it by external?
|
|
|
|
|
Depends. If they are objects that have a Dispose method, then yes, you should call the Dispose method. If not, what can you do ? you can't delete the objects, this is a GC environment, remember ?
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
|
Let's see exactly what happens with your code...
Dim MyCollect as Collection
Set MyCollect = new Collection
Dim Data as Integer
So far nothing surprising. A reference variable is declared, an object is created and it's reference is stored in the variable, and an integer variable is declared.
Data = 1
MyCollect.Add Data
Here it starts to get interresting. You can only store reference types (i.e. objects) in a collection. As an integer is a value type, it can not be stored in the collection, so what happens is that a new object is created automatically, and the integer value is copied to that object. This is called boxing.
Data = 2
MyCollect.Add Data
Data = 3
MyCollect.Add Data
Here you are saved by the boxing. If Data would have been a reference type, the collection would contain a reference and not a separate object, so you would change the contents of the only one object, and you would have ended up with a collection that contained three references to the same object. The boxing creates separate objects for each value, so you get three separate objects in the collection.
What happens after this statement is where it gets really interresting. As the collection isn't used any more in the code, it's now eligible for garbage collection. The garbage collector can determine that the reference to the collection is never read after this, so the reference is deemed inactive from here on. Eventhough the variable contains a reference to the collection, it doesn't count as the reference is inactive, so there are no longer any active references to the collection.
If a garbage collection would happen at this point in the code, the collection and all the objects that it contains could (and most likely would) be garbage collected.
Set MyCollect = Nothing
This statement actually serves no purpose what so ever in your code. As the garbage collector knows that the reference is alredy inactive at this point, you can put whatever you like in the reference, and it will not change how any objects are garbage collected in any way.
Despite everything, the person most likely to be fooling you next is yourself.
modified on Thursday, June 26, 2008 7:23 AM
|
|
|
|
|
In my actual code that is reference type only. and also collection item used in my actual code (using the collection item i did something), at the end i just set nothing to the collection. is it really remove the collection items and delete the items object.
See the sample
Dim MyCollect as Collection
Set MyCollect = new Collection
Dim Nd as Node 'Node - is a our own class object.
MyCollect.Add Nd 'Add 10/15 object to the collection
'Iterate MyCollect and using it by MyCollect.Item(i)
Set MyCollect = Nothing 'What happend in this line.
Is it really remove the items (10/15) and delete object (Node)?
|
|
|
|