﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>StrataFrame Forum / General .NET Discussion / .NET Forums  / SQLParameter question... / Latest Posts</title><generator>InstantForum.NET v4.1.4</generator><description>StrataFrame Forum</description><link>http://forum.strataframe.net/</link><webMaster>forum@strataframe.net</webMaster><lastBuildDate>Fri, 21 Nov 2008 13:58:19 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: SQLParameter question...</title><link>http://forum.strataframe.net/Topic2088-14-1.aspx</link><description>No problem... you can pass anything that implements the IEnumerable interface for that object type, so, if you have an array or a custom object that implements the interface, you can pass it as well.</description><pubDate>Thu, 24 Aug 2006 14:18:58 GMT</pubDate><dc:creator>Ben Chase</dc:creator></item><item><title>RE: SQLParameter question...</title><link>http://forum.strataframe.net/Topic2088-14-1.aspx</link><description>WOW! I never would have thought of that. Thanks!</description><pubDate>Thu, 24 Aug 2006 14:13:21 GMT</pubDate><dc:creator>StarkMike</dc:creator></item><item><title>RE: SQLParameter question...</title><link>http://forum.strataframe.net/Topic2088-14-1.aspx</link><description>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.&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;Dim loParams2 As New System.Collections.Generic.List(Of SqlParameter)(loParams)</description><pubDate>Thu, 24 Aug 2006 14:04:22 GMT</pubDate><dc:creator>Ben Chase</dc:creator></item><item><title>RE: SQLParameter question...</title><link>http://forum.strataframe.net/Topic2088-14-1.aspx</link><description>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?&lt;br&gt;&lt;br&gt;            Dim loParams As New System.Collections.Generic.List(Of SqlParameter)&lt;br&gt;&lt;br&gt;P.S. what does the 'lo' prefix stand for?&lt;br&gt;&lt;br&gt;Thanks&lt;br&gt;&lt;br&gt;</description><pubDate>Thu, 24 Aug 2006 13:22:39 GMT</pubDate><dc:creator>StarkMike</dc:creator></item><item><title>RE: SQLParameter question...</title><link>http://forum.strataframe.net/Topic2088-14-1.aspx</link><description>Thanks!  That's what we're here for! ;)</description><pubDate>Fri, 04 Aug 2006 09:17:13 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item><item><title>RE: SQLParameter question...</title><link>http://forum.strataframe.net/Topic2088-14-1.aspx</link><description>Thanks Trent. You're always full of help. :cool:;)</description><pubDate>Fri, 04 Aug 2006 09:14:32 GMT</pubDate><dc:creator>StarkMike</dc:creator></item><item><title>RE: SQLParameter question...</title><link>http://forum.strataframe.net/Topic2088-14-1.aspx</link><description>If it expects an array then you need to make one simple change:&lt;/P&gt;&lt;P&gt;SqlHelper.ExecuteNonQuery(CONNECTION_STRING, CommandType.StoredProcedure, "StoredProcedureName", &lt;B&gt;loParms.ToArray()&lt;/B&gt;)</description><pubDate>Fri, 04 Aug 2006 09:12:33 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item><item><title>RE: SQLParameter question...</title><link>http://forum.strataframe.net/Topic2088-14-1.aspx</link><description>The reason I was asking this question is because I am using the Data Access Application Block (DAAB) to execute a stored procedure and it accepts sqlparameters as a parameter array.&lt;br&gt;&lt;br&gt;If i understand what you said correctly then this is how I would want my example to look...&lt;br&gt;&lt;br&gt;Dim loParms As New System.Collections.Generic.List(Of [b]SqlParameter[/b])&lt;br&gt;&lt;br&gt;loParms.Add([b]New SqlParameter("@Param1", 1)[/b])&lt;br&gt;loParms.Add([b]New SqlParameter("@Param2", 2)[/b])&lt;br&gt;&lt;br&gt;SqlHelper.ExecuteNonQuery(CONNECTION_STRING, CommandType.StoredProcedure, "StoredProcedureName", [b]loParms[/b])&lt;br&gt;&lt;br&gt;FYI, SqlHelper is a method in the DAAB.&lt;br&gt;</description><pubDate>Fri, 04 Aug 2006 09:07:43 GMT</pubDate><dc:creator>StarkMike</dc:creator></item><item><title>RE: SQLParameter question...</title><link>http://forum.strataframe.net/Topic2088-14-1.aspx</link><description>First of all you can redimension arrays and maintain the contents using the Presernve command:&lt;/P&gt;&lt;P&gt;Redim Preserve MyArray(x)&lt;/P&gt;&lt;P&gt;However, this is an old, and antiquaited way of doing things that just brings frustraion to a developer :)  You will want to use a collection or a generic list.  If you are adding parameters to an SqlCommand, this is not an issue because the Parameters collection is already set for you.&lt;/P&gt;&lt;P&gt;If a = True Then&lt;BR&gt;   loCommand.Parameters.Add(MyParm)&lt;BR&gt;End If&lt;/P&gt;&lt;P&gt;If b = True Then&lt;BR&gt;   loCommand.Parameters.Add(MyParm)&lt;BR&gt;End If &lt;/P&gt;&lt;P&gt;One class that I use all of the time is a generic List().  This allows you to define a collection of any internal type dynamically.&lt;/P&gt;&lt;P&gt;Dim loParms As New System.Collections.Generic.List(Of AnyClass)&lt;BR&gt;&lt;BR&gt;loParms.Add(Class1)&lt;BR&gt;loParms.Add(Class2)&lt;BR&gt;&lt;BR&gt;To clear out the list use the Clear command:&lt;BR&gt;loParms.Clear()&lt;/P&gt;&lt;P&gt;You could also create your own collection and collection items by inheriting the CollectionBase class.  Bottom line is that you are not going to want to use an array in this situation.  You will want to use a collection, list, or dictionary.&lt;/P&gt;&lt;P&gt;Let me know if I need to clear things up. :)</description><pubDate>Fri, 04 Aug 2006 08:44:00 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item><item><title>SQLParameter question...</title><link>http://forum.strataframe.net/Topic2088-14-1.aspx</link><description>Consider this code...&lt;br&gt;&lt;br&gt;If a = True Then&lt;br&gt;   'add sqlparameter to parameter array&lt;br&gt;End If&lt;br&gt;&lt;br&gt;If b = True Then&lt;br&gt;   'add sqlparameter to parameter array&lt;br&gt;End If&lt;br&gt;&lt;br&gt;If c = True Then&lt;br&gt;   'add sqlparameter to parameter array&lt;br&gt;End If&lt;br&gt;&lt;br&gt;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.&lt;br&gt;&lt;br&gt;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?</description><pubDate>Fri, 04 Aug 2006 08:27:11 GMT</pubDate><dc:creator>StarkMike</dc:creator></item></channel></rss>