Alvin Bruney [MVP]
5/5/2007 1:31:00 PM
This is an error, you have ds declared twice, it's most likely a typo. I
wouldn't expect that to compile:
Dim ds As DataSet = Cache("myKey")
dim ds as dataset
When you first create your dataset, it contains a column named customCol.
You can, at any point later, add another column with that name because
column names are explicitly unique.
--
Regards,
Alvin Bruney
------------------------------------------------------
Shameless author plug
Excel Services for .NET is coming...
OWC Black book on Amazon and
www.lulu.com/owc
Professional VSTO 2005 - Wrox/Wiley
"zino" <zino@noemail.noemail> wrote in message
news:4547E8B2-3FD2-4CD4-960B-ABE6F31E69F4@microsoft.com...
> in ASP net 2.0
> a function that query/add item to cache:
> public function1
> ... ... ..
> If HttpContext.Current.Cache(myKey) Is Nothing Then
> Dim ds As DataSet = functionToCreateDataset.... ...
> HttpContext.Current.Cache.Insert(myKey, ds, Nothing)
> End If
> Return HttpContext.Current.Cache
>
> in the web form code behind, I have:
> Dim ds As DataSet = Cache("myKey")
> dim ds as dataset
> ds.Tables(0).Columns.Add("customCol", GetType(String), "col1+'- '+col2")
>
>
> the problem is, when "function1" create the cache the first time, the
> statement:
> ds.Tables(0).Columns.Add("col1", GetType(String), "col1+'- '+col2")
> works fine. But when "function1" returned the cached item, the same
> statement display the error:
> "A column named 'customCol' already belongs to this DataTable."
>
> it looks like the cache get changed too when the dataset derived from it
> is
> changed.
> how can I fix that ?