Home All Groups Group Topic Archive Search About
Author
18 Jan 2006 1:14 PM
Jørn Jensen
According to a Microsoft article a typed dataset is available through
intellisense and can be accessed like in this example:

TextBox1.Text = NorthwindDataSet.Customers(3).ContactName

I have created the Typed DataSet after microsoft recomandations and it's
available in the object browser, but this is where my problem begins..
I work in VB obviously, but the objects from the Dataset apears as C#...
strange. I haven't seen any setting for changing this to VB. I guess this is
the reason I can't access the dataset as in the example above.

Can anyone point me in the right direction, please? That would be much
appreciated!

- Jørn

Author
18 Jan 2006 2:10 PM
Armin Zingler
"Jørn Jensen" <jorn.jen***@mp3pro.no> schrieb
> According to a Microsoft article a typed dataset is available
> through intellisense and can be accessed like in this example:
>
> TextBox1.Text = NorthwindDataSet.Customers(3).ContactName
>
> I have created the Typed DataSet after microsoft recomandations and
> it's available in the object browser, but this is where my problem
> begins.. I work in VB obviously, but the objects from the Dataset
> apears as C#...

Where do you see C# code? Do you get compiler errors? If you can access it
as mentioned above, where do you see the problem?

> strange. I haven't seen any setting for changing this to VB. I guess
> this is the reason I can't access the dataset as in the example
> above.



Armin
Author
18 Jan 2006 2:35 PM
Jørn Jensen
Browsing the Object Browser, the available methods are presented in a C#
syntax, and the root node has a C# icon.

Intellisense shows:

myDataSet.myTableDataTable, myDataSet.myTableRow,
myDataSet.myTableRowChange etc... But no columns.

When I try to compile I get this message:
"Reference to a non-shared member requires an object reference."

This happens compiling only this line of code (in the page_load event)

Dim strTest As String = dsPmsItem.tablePmsItem(3).Artist

The DataSet I created works perfectly when I do a preview from the
DataSet designer.

(thanks for your reply!)

*** Sent via Developersdex http://www.developersdex.com ***
Author
18 Jan 2006 2:45 PM
Armin Zingler
"Jørn Jensen" <jorn.jen***@mp3pro.no> schrieb
> Browsing the Object Browser, the available methods are presented in
> a C# syntax, and the root node has a C# icon.


This is strange. Did you add a new C# project to the solution? (Dumb
question, maybe).


Show quoteHide quote
> Intellisense shows:
>
> myDataSet.myTableDataTable, myDataSet.myTableRow,
> myDataSet.myTableRowChange etc... But no columns.
>
> When I try to compile I get this message:
> "Reference to a non-shared member requires an object reference."
>
> This happens compiling only this line of code (in the page_load event)
>
> Dim strTest As String = dsPmsItem.tablePmsItem(3).Artist
>
> The DataSet I created works perfectly when I do a preview from the
> DataSet designer.


Are you sure you created a dataset object? Is dsPmsItem the name of the
typed dataset class or is it a variable you've declared on your own (or
dropped on the Form using the designer)?


Armin
Author
18 Jan 2006 3:19 PM
Jørn Jensen
I didn't add a C# project =)

I added a DataSet called PmsItem.xsd to the App_Code folder. Then I
completed the wizard, created stored procedures and ended up with a
functioning DataSet. The Table name from my SQL database was pretty
silly, so I changed the Name of the DataSet to dsPmsItem and the name of
the (only) table in the DataSet to tablePmsItem.

I changed the names in the properties window in the DataSet designer and
did a successful "Preview Data..." after.

I tried something new now:

I declared new dataset:

Dim dsPmsItem As New dsPmsItem

And used the same statement on page_load as before:

Dim strTest As String = dsPmsItem.tablePmsItem(0).Artist
lblLabel1.Text = strTest

This worked, but it didn't return anything. And I got an error saying
that that the index number must not exceed the number of rows, or the
column name doesn't not excist, or etc..

The dataset apears to be empty... Obviously, since I created it as New.
How do I fill it?

*** Sent via Developersdex http://www.developersdex.com ***
Author
18 Jan 2006 3:39 PM
Armin Zingler
"Jørn Jensen" <jorn.jen***@mp3pro.no> schrieb
> I didn't add a C# project =)
>
> I added a DataSet called PmsItem.xsd to the App_Code folder.

I'm afraid, I don't know this folder because I'm creating Winforms
applications only.


Show quoteHide quote
> Then I
> completed the wizard, created stored procedures and ended up with a
> functioning DataSet. The Table name from my SQL database was pretty
> silly, so I changed the Name of the DataSet to dsPmsItem and the
> name of the (only) table in the DataSet to tablePmsItem.
>
> I changed the names in the properties window in the DataSet designer
> and did a successful "Preview Data..." after.
>
> I tried something new now:
>
> I declared new dataset:
>
> Dim dsPmsItem As New dsPmsItem
>
> And used the same statement on page_load as before:
>
> Dim strTest As String = dsPmsItem.tablePmsItem(0).Artist
> lblLabel1.Text = strTest
>
> This worked, but it didn't return anything. And I got an error
> saying that that the index number must not exceed the number of
> rows, or the column name doesn't not excist, or etc..
>
> The dataset apears to be empty... Obviously, since I created it as
> New. How do I fill it?


Use a DataAdapter or an OleDBDataReader/SqlDataReader.

More about ADO.Net:
http://msdn.microsoft.com/library/en-us/cpguide/html/cpconaccessingdatawithadonet.asp

"Creating and Using DataSets":
http://msdn.microsoft.com/library/en-us/cpguide/html/cpconcreatingusingdatasets.asp

"Using a DataSet with Existing Data":
http://msdn.microsoft.com/library/en-us/cpguide/html/cpconusingdatasetwithexistingdata.asp

"Populating a DataSet from a DataAdapter":
http://msdn.microsoft.com/library/en-us/cpguide/html/cpconpopulatingdatasetfromdataadapter.asp


Armin