Dataset ExtendedProperties woes

  • Thread starter Thread starter Don
  • Start date Start date
D

Don

I'm working with a dataset to which I've added an extended property like so:


Const KEY_SELECT = "selectquery"
Dim strSQL as String = "Blah blah blah"

dsetTemp.ExtendedProperties.Add(KEY_SELECT, strSQL)


If I try to retrieve the value using the constant to specify the key, I get
a "The parameter is incorrect" error, but if I hardcode the key name it
works:

Console.WriteLine(dsetTemp.ExtendedProperties.Item(KEY_SELECT).ToString)
spits out: "The parameter is incorrect"

Console.WriteLine(dsetTemp.ExtendedProperties.Item("selectquery").ToString)
spits out: "Blah blah blah"


Why doesn't it work when I specify the key with a constant?

- Don
 
Hi Don,

This works for me:
Const x = "tubo"

Dim dst As New DataSet

dst.ExtendedProperties.Add(x, "xxx")

Console.WriteLine(dst.ExtendedProperties.Item(x).ToString())

Are you doing something else?
 
Nope, I'm doing exactly what you're doing. Using your code as an example,
if I were to to type:

Console.WriteLine(dst.ExtendedProperties.Item(x).ToString())

it won't work, but if I were to type:

Console.WriteLine(dst.ExtendedProperties.Item("tubo").ToString())

it will. And I'm 100% sure the constant is storing the correct value...I
passed the constant to define the key in the first place!


Erm...I just ran my code again and now it works. I think my copy of VB.NET
is trying to make me go insane...

- Don
 
Back
Top