Basic N-Tiered structure in VB

P

Paul

I have an xsd file called zTest.xsd. In it, I have a DataTable called
CategoryCountByStore, a TableAdapter that is generated automatically called
CategoryCountByStoreTableAdapter, and a GetMethod name
etCategoryCount )which gets the value from a Stored Procedure). Using
Visual Studio 2005 and testing by Preview Data" it works fine, returning an
integer reflecting a SQL Count. (e.g. running the
preview...Results:CategoryCountByStore = 4, for some StoreID that is filled
in in the value column.)

I have a file under the folder App_Code called Stores.vb. In it, I have the
statement:

Public Function CategoryCountByStore(ByVal StoreID As Integer)
Dim CountCategoriesByStore As New
zTestTableAdapters.CategoryCountByStoreTableAdapter
Return CountCategoriesByStore.GetCategoryCount(StoreID)
End Function

I get no error messages (I know that means little).

Now, I would like to get that value displayed on a WebPage, so I tried, in
the page's code-behind: (The Label2 is in the html section)

Dim myCategoryCount As New Stores
Dim StoreID As Integer = 2
Label2.Text = myCategoryCount.CategoryCountByStore(StoreID).ToString.

But I do not get the value I expected (I get the label saying
CategoryCountByStore).

Could you please go over how to get a value from a DataSet, as Visual Studio
makes easy now, to a Class (object?) and then to the page?

TIA,

Paul
 
P

Paul

Thanks. Where would I cast?


Jorge Bustos said:
Cast "myCategoryCount.CategoryCountByStore(StoreID)" to the appropriate
numeric type before calling to ToString()
 
J

Jorge Bustos

Cast "myCategoryCount.CategoryCountByStore(StoreID)" to the appropriate
numeric type before calling to ToString()
 
J

Jorge Bustos

You should so something like this (I don't use VB, but C#, anyway I think
this is VB's way to do it):

myCategoryCount.CategoryCountByStore(StoreID)
returns a generic object.

CType(int, myCategoryCount.CategoryCountByStore(StoreID))
-> This converts the generic object to a int (You should choose the
appropriate type)

CType(int, myCategoryCount.CategoryCountByStore(StoreID)).ToString()
-> this hopefully will return just what you want

Let me know if this solves your problem.

Jorge
 

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

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top