Typed DataSet

J

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
 
A

Armin Zingler

Jørn Jensen said:
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
 
J

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!)
 
A

Armin Zingler

Jørn Jensen said:
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).

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
 
J

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?
 
A

Armin Zingler

Jørn Jensen said:
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.

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top