Hi
I have a class which inherits the sortedlist collection.
I've overloaded the add method to allow the collection to store
sqlParameters, with the key being the parameter name.
When I try to enumerate using this code:
*****Test Code Start *****
Dim params As New MTXDataLayer.Pa rameters
Dim prm As SqlClient.SqlPa rameter
params.Add("RET URN", SqlDbType.Int)
params.Add("RET URN2", SqlDbType.Int)
params.Add("RET URN3", SqlDbType.Int)
params.Add("RET URN4", SqlDbType.Int)
MsgBox(params.C ount)
For Each prm In params
MsgBox(prm.Para meterName)
Next
*****Test Code End*****
The params.count works giving 4, but the enumeration doesn't.
How can I fix this?
Thanks
Alex Stevens
*****ClassCode Start *****
Public Class Parameters
Inherits System.Collecti ons.SortedList
Public Overloads Function Add(ByVal strParamName As String, ByVal
sqlParamType As Data.SqlDbType, _
Optional ByVal intSize As Integer = 0, Optional ByVal varValue As
Object = Nothing) As SqlClient.SqlPa rameter
Dim sqlParam As New SqlClient.SqlPa rameter
With sqlParam
.ParameterName = strParamName
.SqlDbType = sqlParamType
.Size = intSize
.Value = varValue
End With
Try
Me.Add(sqlParam .ParameterName, sqlParam)
'mColParameters .Add(sqlParam, strParamName)
Catch exc As Exception
Throw New ArgumentOutOfRa ngeException
End Try
Add = sqlParam
sqlParam = Nothing
End Function
End Class
*****ClassCode Code End***** 1 4292
Lookup IEnumerable interface. you have to implement that in order to do
this.
Or IEnumerator, I can't remember which one it is. But one only makes you
use the 3 base functions. If it doens't implement, it doesn't know to
enumerate. Because you need the function getEnumerator() as well.
Welcome to object inheritance and interfacing. =)
"Alex Stevens" <al**@matrixinf otech.co.uk_nos pam> wrote in message
news:eE******** ********@TK2MSF TNGP12.phx.gbl. .. Hi
I have a class which inherits the sortedlist collection.
I've overloaded the add method to allow the collection to store sqlParameters, with the key being the parameter name.
When I try to enumerate using this code:
*****Test Code Start ***** Dim params As New MTXDataLayer.Pa rameters Dim prm As SqlClient.SqlPa rameter
params.Add("RET URN", SqlDbType.Int) params.Add("RET URN2", SqlDbType.Int) params.Add("RET URN3", SqlDbType.Int) params.Add("RET URN4", SqlDbType.Int)
MsgBox(params.C ount)
For Each prm In params MsgBox(prm.Para meterName) Next
*****Test Code End*****
The params.count works giving 4, but the enumeration doesn't. How can I fix this?
Thanks
Alex Stevens
*****ClassCode Start ***** Public Class Parameters
Inherits System.Collecti ons.SortedList Public Overloads Function Add(ByVal strParamName As String, ByVal sqlParamType As Data.SqlDbType, _ Optional ByVal intSize As Integer = 0, Optional ByVal varValue As Object = Nothing) As SqlClient.SqlPa rameter
Dim sqlParam As New SqlClient.SqlPa rameter With sqlParam .ParameterName = strParamName .SqlDbType = sqlParamType .Size = intSize .Value = varValue End With
Try Me.Add(sqlParam .ParameterName, sqlParam) 'mColParameters .Add(sqlParam, strParamName) Catch exc As Exception Throw New ArgumentOutOfRa ngeException End Try
Add = sqlParam sqlParam = Nothing
End Function
End Class *****ClassCode Code End*****
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: DraguVaso |
last post by:
Hi,
I read somewhere that it would be better to use a HashTable or a SortedList
instead of a collection in VB.NET. Is this true and why is this better? Is
it faster or more performant or ...?
Any info would be nice!
Pieter
|
by: gerrod |
last post by:
Hi -
Does anyone know a way to created a SortedList (in the
System.Collections namespace) that will sort on VALUES instead of
KEYS... ?
The scenario is this - I have a SortedList containing key-value pairs
of UserID - DisplayName for a whole bunch of user objects. The UserID
is simply a long, the DisplayName is something like, "Jones, Bill". I
want the SortedList to sort the names alphabetically, rather than by
|
by: arby |
last post by:
Hi There.
I have a SortedList collection that I add objects of a custom class
to. Rather then explain my app, my question is pretty general so....
Using a simple clsDog:
***************************
clsDog boomer = new clsDog();
clsDog spot = new clsDog();
|
by: nevin |
last post by:
Hello all,
I've looked on the net and can't seem to find what I need so I must be
searching badly or have (another) 'non-problem'.
I am simply trying to move the values of a hastable or sorted list into a
combobox control. I'm willing to lose the key item of the collection I just
need the values.
Surely i don't need to enumerate the entire collection adn add the values
one by one into the combobox?
|
by: Chris Bardon |
last post by:
I'm working on a class library in .net, and am having a problem that I
can only describe as a memory leak (which garbage collection was
supposed to eliminate). My class library contains a single class, one
member of which is a static SortedList of session data objects. One
of my methods creates a new object on this list, and another removes
the item from the list, which should make it eligible for garbage
collection. I've tested this in...
| |
by: enchantingdb |
last post by:
I'm trying to add the contents of a ListView to a SortedList. The
ListView contains two columns - "Title" and "URL". I need to add both
columns to the SortedList with Title being the Value and URL being the
Key. I can get the information into and out of the SortedList but when
I add the URL into the SortedList it is in the form "ListViewSubItem:
{http://...}". The code I use for this is...
ListView.CheckedListViewItemCollection...
|
by: john conwell |
last post by:
So you pass in the Key and it returns the array index of the key. but you
cant do array index lookups. the indexer of the sortedlist does a binary
search based on the key. So whats the pointof this method? is there a way
to return a array item based on the index?
|
by: semedao |
last post by:
Hi,
I want to implement list of key-values that can be sort by 2 ways.
let's say that in the first step I wanted to make SortList based on Key = int index that cannot change and Value is another SortedList like this:
class OtherSortedList : SortedList
{
.....
int GetTotalAmountOfAllItems()....
}
|
by: raylopez99 |
last post by:
I seem to get name collision between the Generic collection SortedList
and C++.NET Framework collection SortedList.
How to resolve? Here are the libraries that seem to clash:
System::Collections::SortedList,
System::Collections::Generic::SortedList,
using namespace System::Collections;
using namespace System::Collections::Generic;
Below is a working version of the generic template SortedList, which
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
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 we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |