SQLParameter question...


Author
Message
StarkMike
StarkMike
Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)
Group: Forum Members
Posts: 436, Visits: 944
Consider this code...



If a = True Then

'add sqlparameter to parameter array

End If



If b = True Then

'add sqlparameter to parameter array

End If



If c = True Then

'add sqlparameter to parameter array

End If



Each time this code runs the parameter array could change sizes... The first time it could contain only one parameter... the second time it runs it could contain three parameters.



How do i define the parameter array when i dont know how many dimensions I'll need, and how do I add parameters to the array?
Replies
StarkMike
StarkMike
Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)
Group: Forum Members
Posts: 436, Visits: 944
Ok, so now how do I create a copy of this generic list? I've done a little research and i dont think it implements the ICloneable interface so I cant use the Clone method. A couple of places I have found tell me just to use a For Each loop to add the existing objects from list A to list B. It works but it doesnt seem like the BEST way. Is it? or should I use a different type list/collection that does implement the ICloneable interface... which one would I use?



Dim loParams As New System.Collections.Generic.List(Of SqlParameter)



P.S. what does the 'lo' prefix stand for?



Thanks



StrataFrame Team
S
StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
The 'lo' prefix is a hold-over from the FoxPro days when we had weak-typing and we had the prefix for the Hugarian notation to tell us what the variable represented; the 'lo' stands for local object.

The best way to create a copy of the list is through the copy constructor and you just pass the first list to the constructor of the second list.

Dim loParams2 As New System.Collections.Generic.List(Of SqlParameter)(loParams)

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...





Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search